Declarative Pipeline Quick Reference

Declarative Pipeline Quick Reference

Declarative Pipeline Quick Reference Jenkins Pipeline enables users to build complete continuous pipeline { delivery (CD) pipelines as part of their application code. The agent { steps to build, test and deliver each application become part docker { of the application itself, stored in a Jenkinsfile. Declarative label ‘docker-node’ image ‘maven’ Pipeline syntax offers a simple, predefined hierarchy to make args ‘-v /tmp:/tmp -p 80:80’ the creation of pipelines and the associated Jenkinsfiles } accessible to users of all experience levels. In its simplest } form, a pipeline runs on an agent and contains stages, while environment { each stage contains steps that define specific actions. GIT_COMMITTER_NAME = ‘jenkins’ } options { timeout(6, HOURS) pipeline { } agent { stages { label ‘’ stage(‘Build’) { } steps { stages { sh ‘mvn clean install’ stage(‘Build’) { } steps{ } sh ‘mvn install’ stage(‘Archive’) { } when { } branch ‘*/master’ } } } steps { archive ‘*/target/**/*’ In addition, Declarative Pipeline syntax also provides junit ‘*/target/surefire-reports/*.xml’ } the ability to control all aspects of the Pipeline execution } environment in a straightforward format. For example, } building a Java application with Maven in a Docker container post { that only archives and tests the “Master” branch and times always { out after six hours. deleteDir() } } https://jenkins.io/doc/book/pipeline/ } DECLARATIVE PIPELINE SYNTAX - REQUIRED DECLARATIVE PIPELINE SYNTAX - OPTIONAL » pipeline - Contains the entire Jenkins Pipeline definition » environment - A sequence of “key = value” pairs » agent - Defines the agent used for the entire Pipeline to define environment variables or a stage • credentials(‘<id>’) - Bind credentials to variable • label - Existing Jenkins node label » options - Options for the entire Pipeline. For example: • docker - Requires Docker-enabled node • skipDefaultCheckout - Disable auto checkout SCM - image - Run inside specified Docker image • timeout - Sets timeout for entire Pipeline - label - Existing Jenkins node label • buildDiscarder - Discard old builds - args - Arguments for Docker container • disableConcurrentBuilds - Disable concurrent • dockerfile - Use a local Dockerfile Pipeline runs - filename - Name of local Dockerfile » tools - Installs pre-defined tools to be available on PATH - label - Existing Jenkins node label » triggers - Triggers for Pipeline based on schedule, polling, etc. - args - Arguments for Docker container Pipeline parameters that are prompted for » stages - Contains Pipeline stages and steps » parameters - at run time » stage - A specific named “stage” of the Pipeline » post - Defines actions to be taken when pipeline or stage • steps - One or more build steps that define the actions completes based on outcome. Conditions execute in order: in the stage. Contains one or more of the following: • always - Run regardless of Pipeline status - Any build step or build wrapper defined in Pipeline • Run if the result of Pipeline has changed e.g. sh, bat, timeout, echo, archive, junit, etc. changed - from last run - parallel (optional) - Execute steps in parallel. May not be used with other steps • success - Run if Pipeline is successful • Run if Pipeline result is unstable - script (optional) - Execute Scripted Pipeline block unstable - • Run if the Pipeline has failed • when (optional) - Runs stage conditionally failure - - branch - Stage runs when branch name matches expression - Boolean expression - Created by CloudBees • agent, environment, tools and post may also optionally be defined instage .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us