January 5, 2021
Estimated Post Reading Time ~

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 an 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. The quality team can then test the feature/bugfix on the 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 kick off the build, deploy packages to AEM Integration Server. When too many changes are being pushed to the repo, the 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 the 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
3) 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 the Jenkins console. So it allows anyone to creates 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 the 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 a remote repository. For this post, use sample repo experience-aem-intranet created in this post

4) Add the path to GIT executable on the 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 they 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 webhook can be configured in GIT to trigger a build automatically when there is a commit on the build branch say develop


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.