DevSecOps Course Labs

Lab Solution

The simplest way is to copy the previous job:

In the build definintion, scroll to Build triggers and select Poll SCM. That sets up a schedule to check for changes from the Git server; enter this in the Schedule box:

* * * * * 

This means Jenkins will check the Git repo every minute, and if there have been any changes since the last build then a new one is triggered.

Change the script path to labs/jenkins/hello-world/Jenkinsfile, then save and build the job - it fails.

Check the logs or the console output - the Test stage fails with this log line:

Error: Could not find or load main class HelloWorkd.java

HelloWorkd> Looks like a typo :)

Change the line java HelloWorkd in the Jenkinsfile to java HelloWorld in the file labs/jenkins/hello-world/Jenkinsfile. My fixes are in this Jenkinsfile

Then commit and push your changes. Back in Jenkins, wait for the build to trigger from the SCM change (or click Build Now).

All will be well. Check the output page for the build and you'll see a list of archived artifacts, containing the Java class file.


Back to the exercises.