Jenkins Pipeline Examples

Nidhi
2 min readApr 5, 2018

Please visit my website and subscribe to my youtube channel for more articles

https://devops4solutions.com/

It is used to create stages/pipeline of all the steps which are required for building the project.

How to initialize software and set path

stage(‘Terraform Init’) {
steps {
script {
def tfHome = tool name: ‘Terraform’
def anHome = tool name: ‘Ansible’
env.PATH = “${anHome}:${env.PATH}”
env.PATH = “${tfHome}:${env.PATH}”
}
sh ‘terraform — version’
sh ‘ansible — version’

}
}

How to declare variable

def my_list

pipeline {
agent any
stages {
stage(‘stage1’) {
steps {
script {
my_list = “nidhi”
}
}
}

stage(‘stage2’) {
steps {
echo “$my_list”

}
}
}
}

Second Example
def test=”nik”

pipeline {
agent any
stages {



stage(‘stage2’) {
steps {
echo “$test”

}
}
}
}

Example of pipeline which will use variables/checkout/dockerpush

Nidhi

Devops Automation Enginneer