jenkins学习笔记-5-清理和通知
2017-08-22 09:06
148 查看
清理和通知
由于post是约定在通道的最后部分执行的,我们可以增加一些通知或者其他执行终止、通知的步骤或者其他其他管道终止的任务Jenkinsfile(Declarative Pipeline)
pipeline{
agentany
stages{
stage(‘No-op’){
sh’ls’
}
}
post{
always{
acho ‘oneway or another,I have finished’
deleteDir()/** clean up our workspace */
}
success{
echo ‘Isuccessed!’
}
unstable{
echo ‘I amunstable :/’
}
failure{
echo ‘Ifailed :(’
}
changed{
echo‘things were different before …’
}
}
}
Toggle Scripted Pipeline
(高级)
Jenkinsfile (Scripted Pipeline)
node {
try {
stage('No-op') {
sh 'ls'
}
}
}
catch (exc) {
echo 'I failed'
}
finally {
if (currentBuild.result ==
'UNSTABLE') {
echo 'I am unstable :/'
} else {
echo 'One way or another, Ihave finished'
}
}
有很多种发送通知的方式,下面是一个演示如何通过邮件,聊天室,或松弛的管道发送消息的小片段
post{
failure{
mail to : ‘team@example.com’,
subject:”FailedPoleline:${currentBuild.fullDisplayName}”,
body:”Something is wrong with${env.Build_url}”
}
}
Hipchat
post{
failure{
hipchatSend message:”Attention @here${env.JOB_NAME} #${env.BUILD_NUMBER} has failed.”
color:’RED’
}
}
Slack
post{
success{
slackSendchannel :’#ops-room’,
color :’good’,
message:The pipeline ${currentBuild.fullDisplayName}completed successfully”
}
}
既然我们的团队成员可以在事务出现失败,不稳定甚至是成功时被通知,那么我们可以通过令人兴奋的部分完成持续交付管道:运送(shipping
)
相关文章推荐
- Spring学习笔记 关于Bean的初始化和清理-init和destroy方法
- Jenkins 使用学习笔记
- jenkins学习笔记-官网翻译
- Jenkins 学习笔记
- Windows phone 8 学习笔记(5) 图块与通知(转)
- iOS学习笔记-----KVC,KVO与通知初探
- iOS学习笔记22-推送通知
- jenkins学习笔记1
- Effective C# 学习笔记(二十五)以事件机制来实现通知
- iOS学习笔记48-iOS本地推送(本地通知)
- R学习笔记 第六篇:数据变换和清理
- jenkins 自动部署-windows下的-学习笔记 ( 四 )
- java编程思想学习笔记(5)--初始化与清理
- Webkit 桌面通知 学习笔记 (HTML5 webkitNotifications)
- iOS通知学习笔记(NSNotification)
- [oc学习笔记]通知中心传值的使用
- jenkins学习笔记-2-定义运行环境
- jenkins 自动部署-windows下的-学习笔记 ( 一 )
- spring学习笔记十四 五种通知
- iOS学习笔记45—本地通知UILocalNotification