How Do You Use the Docker Pipeline Plugin with Jenkins?

Problem scenario
You want to use the Docker Pipline (with the Jenkins ID of "docker-workflow"). What do you do?

Jenkins needs to be installed. If you need assistance, see this posting if you are using a CentOS/RHEL/Fedora server; if you want to install Jenkins on a Debian/Ubuntu server, see this posting. With modern versions of Jenkins (as of 9/24/19), we find that the Docker pipeline has been installed. (If you have an older version of Jenkins install the Docker Pipeline plugin manually.)

1.a. Run this command from the back-end: sudo usermod -a -G docker jenkins
1.b. Restart the Jenkins service (e.g., with sudo systemctl restart jenkins).
1.c. Open a web browser. Log into the web UI for Jenkins as an administrator.

2.a. If you see "New Item" do 2.b, otherwise do 2.c.
2.b. Click on "New Item".
2.c. Click on "Dashboard" if you do not see "New Item." Then click "New Item".

3. Enter a name in the field and the top, then click on "Pipeline". Then click "OK".

4.a. Scroll down to the "Pipeline" section.
4.b. Enter this text:

pipeline {
     agent {
         docker { image 'node:7-alpine' }
     stages {
         stage('Test') {
             steps {
                 sh 'node --version'

Leave a comment

Your email address will not be published. Required fields are marked *