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



4) Two sample users eaem, nalabotu were created in local OpenLDAP database



JDK, GIT, Maven Configuration

1) Access the configuration screen, Manage Jenkins -> Configure System (http://localhost:8080/configure)


2) Configure the JDK used for compiling sources




3) Configure the GIT plugin to download sources from remote repository. For this post, use sample repo experience-aem-intranet created in this post


4) Add the path to GIT executable on file system, used for checking out source code



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)


2) Enter name experience-aem-intranet-portal and select the project type Maven


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






4) Specify the relative path of pom.xml; the goal autoInstallPackage builds, installs packages to provided CQ instance, here its localhost

                 clean install -X -P autoInstallPackage -Dcrx.host=localhost -Dcrx.port=4502 -Dcrx.user=admin -Dcrx.password=admin -Dvault.timeout=30

5) Run the build by clicking Build Now


6) Build creates a workspace with sources downloaded from remote GIT repo


7) Packages are Installed on AEM running on localhost:4502


8) If the GIT repo can communicate with Jenkins, a web hook can be configured in GIT to trigger a build automatically when there is a commit on build branch say develop


3 comments:

  1. How to configure build for author as well as publish?

    ReplyDelete
  2. You can set the Java Versions available Globally through /configureTools/ after version 2.0, /configure before version 2.0.

    ReplyDelete