pipeline { agent any
stages { stage('Deploy'){ steps { retry(3){ sh './flakey-deploy.sh'} timeout(time: 3, unit: 'MINUTES'){ sh './health-check.sh'}}}}}
邮件 🔗
1
2
3
4
5
6
7
post { failure { mail to: 'team@example.com',
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "Something is wrong with ${env.BUILD_URL}"}}
pipeline { agent any
stages { stage('Test'){ steps { sh 'echo "Fail!"; exit 1'}}} post { always {echo'This will always run'} success {echo'This will run only if successful'} failure {echo'This will run only if failed'} unstable {echo'This will run only if the run was marked as unstable'} changed {echo'This will run only if the state of the Pipeline has changed'echo'For example, if the Pipeline was previously failing but is now successful'}}}
dir 切换jenkins中工作目录 🔗
pipeline中用于切换目录
1
2
3
4
5
6
7
steps { sh "pwd" dir('your-sub-directory'){ sh "pwd"} sh "pwd"}
Use WORKSPACE environment variable to change workspace directory.