Creating your first Pipeline

What is a Jenkins Pipeline?

Jenkins Pipeline (or simply "Pipeline") is a suite of plugins which supports implementing and integratingcontinuous delivery pipelinesinto Jenkins.

Acontinuous delivery pipelineis an automated expression of your process for getting software from version control right through to your users and customers.

Jenkins Pipeline provides an extensible set of tools for modeling simple-to-complex delivery pipelines "as code". The definition of a Jenkins Pipeline is typically written into a text file (called aJenkinsfile) which in turn is checked into a project’s source control repository.[1]

For more information about Pipeline and what aJenkinsfileis, refer to the respectivePipelineandUsing a Jenkinsfilesections of the User Handbook.

To get started quickly with Pipeline:

  1. Copy one of theexamples belowinto your repository and name itJenkinsfile

  2. Click theNew Itemmenu within JenkinsClassic UI left column

  3. Provide a name for your new item (e.g.My-Pipeline) and selectMultibranch Pipeline

  4. Click theAdd Sourcebutton, choose the type of repository you want to use and fill in the details.

  5. Click theSavebutton and watch your first Pipeline run!

You may need to modify one of the exampleJenkinsfile's to make it run with your project. Try modifying theshcommand to run the same command you would run on your local machine.

After you have setup your Pipeline, Jenkins will automatically detect any new Branches or Pull Requests that are created in your repository and start running Pipelines for them.

Quick Start Examples

Below are some easily copied and pasted examples of a simple Pipeline with various languages.

Java

Jenkinsfile (Declarative Pipeline)
pipeline { agent { docker { image'maven:3.8.4-openjdk-11-slim'} } stages { stage('build') { steps { sh'mvn --version'} } } }

Node.js / JavaScript

Jenkinsfile (Declarative Pipeline)
pipeline { agent { docker { image'node:16.13.1-alpine'} } stages { stage('build') { steps { sh'node --version'} } } }

Ruby

Jenkinsfile (Declarative Pipeline)
pipeline { agent { docker { image'ruby:3.0.3-alpine'} } stages { stage('build') { steps { sh'ruby --version'} } } }

Python

Jenkinsfile (Declarative Pipeline)
pipeline { agent { docker { image'python:3.10.1-alpine'} } stages { stage('build') { steps { sh'python --version'} } } }

PHP

Jenkinsfile (Declarative Pipeline)
pipeline { agent { docker { image'php:8.1.0-alpine'} } stages { stage('build') { steps { sh'php --version'} } } }

Go

Jenkinsfile (Declarative Pipeline)
pipeline { agent { docker { image'golang:1.17.5-alpine'} } stages { stage('build') { steps { sh'go version'} } } }


Was this page helpful?

Please submit your feedback about this page through thisquick form.

Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?


See existing feedbackhere.

Baidu