Install Jenkins on the AWS EC2 Amazon Linux instance, as root.
$ sudo -i
# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
# rpm --import http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key
# yum install jenkins
# service jenkins start
# chkconfig jenkins on
Access Jenkins UI on the browser at http://IP-ADDRESS:8080. When prompted for the password, get that from following file on the EC2 host:
$ cat /var/lib/jenkins/secrets/initialAdminPassword
Click "Install Suggested Plugins" button.
Create a new admin user after logged in to Jenkins.
Click on New Item
Enter simple-build as the job name and select Freestyle project.
Under Source Code Management tab:
- Select Git and
- for
Repositories -> Repository URLenterhttps://github.com/kurianinc/docker-java-sample.git - for
Branches to build -> Branch Specifierreplacemasterwith name of your branch you created during Git tutorial.
- for
Under Build Triggers tab:
- Check
Poll SCMand in theSchedulefield enter* * * * *. This means Jenkins is scheduled to poll the Git repo/branch every minute for a changes. If there would be any change Jenkins will kick off a build.
Under Build tab:
Add build step->Execute shelland in theCommandfield enter:
mvn package
mvn exec:java
Save the job. In a minute you will see that Jenkins would trigger a build. You can also kick off a build manually by clicking on the Build Now link.
To view the build output, click on the Build Number in the Build History and then click on the Console Output link.
Check in changes to docker-java-sample repo, as you have learned in the Git tutorial, and verify that Jenkins picks that up and builds. (Make changes to the src/main/java/org/examples/java/App.java file from the Git Tutorial on the branch you created, commit the changes, and push the changes.)
Click on Jenkins -> Manage Jenkins -> Manage Plugins
Select Available tab and filter by Artifactory. Select Artifactory and click the button Install without Restart.
Check Restart Jenkins when installation is complete and no jobs are running. This will trigger restart of Jenkins instance. Log back in when the instance is back online again.
Click Jenkins -> Manage Jenkins -> Configure System.
Scroll down to the section Artifactory. Click the "Add Artifactory Server" button.
In Artifactory servers:
- Enter
bootcamp-artifactoryforServer ID - Enter
http://34.212.154.26:8081/artifactory(later change to own URL when Artifactory is set up) forURL. - For
Default Deployer Credentialsenter Artifactory admin user creds. - Click
Test Connectionbutton. You will see a messageFound Artifactory 6.0.1.
Check out the Artifactory Tutorial Repository and follow those steps.
Click on New Item
Enter artifactory-integration as the job name and select Freestyle project, do not click 'OK' yet- in Copy from enter simple-build and click OK button.
Check Build Environment (top middle tab on top) -> Generic-Artifactory Integration.
- Make sure
Artifactory upload serverfield is filled with the Artifactory URL. - Pick
Job configurationforUpload spec source - In
Specfield for Upload, enter following configuration:
{
"files": [
{
"pattern": "target/*.jar",
"target": "bootcamp/builds/libs/"
}
]
}
Click Save.
Click Manage Jenkins -> Configure System (top item).
Scroll down to Jenkins Location.
- Update
System Admin e-mail addressto a valid email address. Example:Thomas TK <thomas123@gmail.com>
Click Save button.
Make sure that sendmail service is running on the host:
$ sudo service sendmail status
sendmail (pid 2750) is running...
sm-client (pid 2759) is running...
Click on one of the build jobs - simple-build or artifactory-integration.
Click Configure on the left pane.
Scroll down to Post-build Actions (right most tab on top). Pick E-Mail notification.
- Enter a valid e-mail address in the
Recipientsfield. - Make sure
Send e-mail for every unstable buildis checked.
Click Save button.
Add some bug by making a syntax error in src/main/java/org/examples/java/App.java and check that change into your branch.
Wait for the build to get triggered and the email notification be sent. The email might be in the Spam folder.
Fix the syntax error and repeat the check in step and check if you get a back to normal notification.
E-mail notification format can be customized by changing the configuration info at Manage Jenkins -> System Configuration -> Extended E-mail Notification.