JENKINS PIPELINE JENKINS 2 0 Presented By Amrit

  • Slides: 7
Download presentation
JENKINS PIPELINE JENKINS 2. 0 Presented By: Amrit Choudhary

JENKINS PIPELINE JENKINS 2. 0 Presented By: Amrit Choudhary

What is pipeline ? ? ? Series of steps which orchestrates work required to

What is pipeline ? ? ? Series of steps which orchestrates work required to Build , test, deploy applications. They are defined in a file called Jenkinsfile which is stored in the root of the project repository Requirements: a) Jenkins 2. 0 & above b) Maven, git installed in Jenkins global tool configuration section c) Get code form git repo https: //github. com/amritsql/maven_java_tutorial. git

Pipeline example … Jenkinsfile pipeline { agent { label "windows" } tools { maven

Pipeline example … Jenkinsfile pipeline { agent { label "windows" } tools { maven 'Maven 3. 1. 1' jdk 'java 8' } stages { stage ('Initialize') { steps { bat ''' echo "PATH = %PATH%" echo "M 2_HOME = %M 2_HOME%" ''' } } pipeline: pipeline definition agent: mention Jenkins label/agent run tools: usage of existing Jenkins tools from manage Jenkins/global tools stage: what to run at particular stage steps: divides stage into steps stage ('Build') { steps { bat 'cd Number. Generator & mvn install' } post { success { junit 'Number. Generator/target/surefire-reports/*. xml' } } } post : action to perform if steps fail/pass

Jenkins : Pipeline • We need to commit this Jenkinsfile in out repository(Git/SVN etc.

Jenkins : Pipeline • We need to commit this Jenkinsfile in out repository(Git/SVN etc. ) • Select the existing tools configured in Manage Jenkins -> Global tool configuration • Creating a new pipeline job • Steps) • A) Create a new job and select below option, click ok

Jenkins : Pipeline • B) provide pipeline name and description as given below •

Jenkins : Pipeline • B) provide pipeline name and description as given below • C) Select “pipeline script from scm” as we are placing our Jenkinsfile in repository which will detect the changes, also by this method Jenkins takes care of SCM checkout of code stage automatically • D) Enter the repository, credentials, select the branch. Finally provide relative location of your Jenkinsfile, make sure to check the lightweight checkbox.

Jenkins : Pipeline • Your pipeline run job will look like below

Jenkins : Pipeline • Your pipeline run job will look like below

Jenkins : generate script DSL • We can generate the pipeline script using Jenkins

Jenkins : generate script DSL • We can generate the pipeline script using Jenkins • Go to configure section of the job created by you for pipeline and click on the • Highlighted section as shown below • Which takes you to below page, where you can select “sample step from the dropdown, enter some values in test box and click on “Generate Pipeline Script”, which generates the pipeline script syntax