Jenkinsfile 介绍 Posted on 2020-02-15 | In CI Jenkinsfile 是用来定义 jenkins pipeline的构建流程。 Jenkinsfile 主要有以下几个部分组成: tools: 需要使用的工具; agent: 构建的节点; stages: 构建流程,可以由多个 stage 组成; post: 构建后处理 12345678910111213141516171819202122232425262728293031323334353637pipeline { tools { maven "Maven 3.3.9" jdk "Oracle JDK 8u40" } agent { label "any-executor" } stages { stage("build") { steps { sh 'echo "path: ${PATH}"' sh 'echo "M2_HOME: ${M2_HOME}"' sh 'mvn clean install -Dmaven.test.failure.ignore=true' } } } post { always { archive "target/**/*" junit 'target/surefire-reports/*.xml' } success { mail to:"me@example.com", subject:"SUCCESS: ${currentBuild.fullDisplayName}", body: "Yay, we passed." } failure { mail to:"me@example.com", subject:"FAILURE: ${currentBuild.fullDisplayName}", body: "Boo, we failed." } unstable { mail to:"me@example.com", subject:"UNSTABLE: ${currentBuild.fullDisplayName}", body: "Huh, we're unstable." } changed { mail to:"me@example.com", subject:"CHANGED: ${currentBuild.fullDisplayName}", body: "Wow, our status changed!" } }}