Difficulty: Advanced
Estimated Time: 15-20 minutes

In this scenario you'll dig into an increasingly popular Jenkins plugin named Pipeline. It uses Groovy scripts to define Jenkins workflows as code.

The scenario is designed to demostrate how you can use Groovy Pipelines within a Continuous Intagration/Delivery (CI/CD) workflow to download software code from GitHub, perform unit tests and display a historical test result report.

You will learn how to make use of a Docker host environment for running Jenkins in a Docker container. The steps guide you to installing the required plugins, creating and running a Software build process build and viewing the test report results.

For a more verbose introduction into the Pipeline plugin, see this blog post.

This scenario has started a Jenkins Docker container to configure and run Jenkins Pipelines. With an example project that is throwing random unit test failures, we have demonstrated, how to create and display a test report trend graph.

Coming soon: Learn how to automatically trigger a Pipeline workflow with our triggered pipeline scenario.

Jenkins Pipelines

Step 1 of 7

Launch Jenkins

We will prepare an environment with a Jenkins server running as a Docker Container.

Note: steps 1 to 4 can be skipped, if you want to head directly to the pipeline section. We will provide a pre-configured Jenkins image in step 5.

First we start the container in detached mode with a tail to a log file we will create and use later:

docker run -d -u root --rm --name jenkins \ -p 8080:8080 -p 50000:50000 \ --entrypoint bash \ jenkins:2.46.2-alpine \ -c "tail -F /jenkins.log"

With the next command, we clone a Jenkins Home directory into the container, before we start the Jenkins application. The Jenkins Home directory has been prepared to allow us using Jenkins without any login:

docker exec -d jenkins \ bash -c 'git clone https://github.com/oveits/jenkins_home_alpine \ && export JENKINS_HOME=$(pwd)/jenkins_home_alpine \ && java -jar /usr/share/jenkins/jenkins.war 2>&1 1>/jenkins.log &'

After a minute or so, we should see that the jenkins.war is started:

docker exec jenkins ps -ef

Load Dashboard

You can load the Jenkins' dashboard via the following URL https://[[HOST_SUBDOMAIN]]-8080-[[KATACODA_HOST]].environments.katacoda.com/ or by clicking the dashboard tab on the right (note: sometimes, you need to wait a few seconds and press "display port" at this point).

In the next steps, you'll use the dashboard to configure the plugins and start building Docker Images.