Saturday, July 28, 2018
AEM Continuous Integration with Jenkins
AEM Continuous Integration with Jenkins
Goal
For Source Code Management using GIT (Bitbucket) check this post
Jenkins is a continuous integration tool (CI) for automating builds. In simple terms, developers in a AEM project code a feature or bugfix, test on their local instances, commit/push to a central SVN or GIT repo; continuous integration tools like Jenkins kick off, build packages and deploy to some common AEM test/integration servers. Quality team can then test the feature/bug fix on AEM integration server
In a nutshell...
1) Developer starts working on a feature/bug-fix, marks the story in JIRA as In Progress
2) Tests the code on local AEM
3) Commits/Pushes change to the SVN/GIT repo. For source code management using GIT check this post
4) A configured Jenkins Hook in GIT can kickoff the build, deploy packages to AEM Integration Server. When too many changes are being pushed to the repo, admin may choose to manually start builds through Jenkins console (Jobs), to refresh integration environments.
5) Developer moves the story to QA
6) Quality team picks up the story and tests code changes on Integration Server.
Build Demo
Install Jenkins
1) Get Jenkins for Windows here
2) Run install with default settings. For more refined steps check this link
2) When completed, service Jenkins is available and a browser window opens up with url http://localhost:8080/
Configure Jenkins Global Security
1) After installation, by default, no authentication is required for accessing jenkins console. So it allows anyone create a job, right away
2) To secure Jenkins, enable Global Security (Manage Jenkins -> Configure Global Security) http://localhost:8080/configureSecurity/
3) A Jenkins internal database of users can be created by selecting Jenkins� own user database option or connect to organization LDAP. In the following example, Jenkins was connected to ldap on localhost:389 (a sample OpenLDAP database). So any logged-in user can modify the configuration, create jobs etc, a more fine grained access control can be set by selecting Matrix-based security
JDK, GIT, Maven Configuration
1) Access the configuration screen, Manage Jenkins -> Configure System (http://localhost:8080/configure)
3) Configure the GIT plugin to download sources from remote repository. For this post, use sample repo experience-aem-intranet created in this post
5) Configure MAVEN install, required for running any typical AEM project build
6) Restart Jenkins service
Creating Build Jobs
1) Create new job (If not already logged-in, login as user, say eaem)
3) Configure the GIT repository url and credentials. The Branches to build specifies which branch of the repo should be downloaded and compiled, here its develop
clean install -X -P autoInstallPackage -Dcrx.host=localhost -Dcrx.port=4502 -Dcrx.user=admin -Dcrx.password=admin -Dvault.timeout=30