Continuous Delivery with Jenkins CI
Continuous delivery jobs with Jenkins
Make sure Jenkins is started, and no other programs, such as an app running in the SpringSource Tool Suite, or a running Java JAR file, is blocking port 8080.
The Jenkins URL is: http://localhost:8080
Spring Boot Jenkins Builds
Here’s a quick example of how to do continuous delivery with Jenkins. In this example, we not only build a Spring Boot app with Maven, but we run the JAR file that gets created and we test the JSON returned from a web based invocation.
Here is the GitHub repository used in the example:
https://github.com/cameronmcnz/rps-maven
The Maven command used is:
clean compile package
The code used in the second build step is available here:
https://raw.githubusercontent.com/cameronmcnz/rps-maven/main/website-status-check.txt
Ever wonder why does Jenkins uses blue spheres? (My interview with Kohsuke Kawaguchi)
Quick Look at Plugins
I’d like to take a quick look at plugins. Very quick.
Two things you’ll need for this exercise:
https://github.com/cameronmcnz/rock-paper-scissors.git clean install pmd:pmd checkstyle:checkstyle findbugs:findbugs
Install Warnings Next Generation Plugin
You can follow along, but just watching is fine too.
To follow along:
- Start Jenkins (wasadmin/wasadmin on localhost:8080)
- Click ‘Manage Jenkins’ on the left and look for ‘Manage Plugins’
- Look for the ‘Warnings Next Generation’ plugin. Make sure you click the Avaliable tab, as shown in the image below.
- Click the Checkbox next to ‘Warnings Next Generation’ and then click the “Install without Restart”
Note: Because a few plugins are a bit stale, the install may initially fail, you’ll need to restart, and then do the installation a second time.
To reboot Jenkins:
Click the start button on Windows in the lower left, and right-click on the command prompt and choose ‘Run as Administrator’
cd C:\Program Files (* cd jenk* jenkins stop jenkins status jenkins start
Create a build job
Create a freestyle build job named rock-paper-errors
Set the Git repository as:
https://github.com/cameronmcnz/rock-paper-scissors.git
Build Step
Add the foll0wing build step as:
Invoke Top Level Maven Targets
clean install pmd:pmd checkstyle:checkstyle findbugs:findbugs
POST Build Step
Add the Record copmiler warnings and static analysis results option as a post build step.
Click the ‘Add Tool’ option a few times to add PMD, Findbugs and Checkstyle.
Then run the build!
There’s a video that describes the process on theserverside.
Pipeline Code
node { stage('Checkout') { git url: 'C:\\Software\\repos\\SimpleGreeting.git' } stage ('User Acceptance Test') { def response = input message: 'Is this build good to go?', parameters: [choice(choices: 'Yes\nNo', description: '', name: 'Pass')] if (response=="Yes") { stage('Deploy') { bat 'gradle build -x test' } } } }