美文网首页
pipeline demo

pipeline demo

作者: AppleLin_cdea | 来源:发表于2021-10-12 17:23 被阅读0次

jenkins pipleline 的例子 try catch finally简单应用
2021年10月12日17:17:57 星期二

Pipeline script

import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
node('general')
{
    try {
        echo '1. ls aaa'
        sh """ls aaa"""
    } catch(e){
        echo "2. Exception is " + e
    } finally {
        echo "3. finally"
    }
}

运行结果

Console Output
17:14:45 Started by user Apple
17:14:45 Running in Durability level: MAX_SURVIVABILITY
17:14:45 [Pipeline] Start of Pipeline
17:14:45 [Pipeline] node
17:14:45 Running on general in /home/jenkins/workspace/demo
17:14:45 [Pipeline] {
17:14:45 [Pipeline] echo
17:14:45 1. ls aaa
17:14:45 [Pipeline] sh
17:14:46 + ls aaa
17:14:46 ls: cannot access 'aaa': No such file or directory
17:14:46 [Pipeline] echo
17:14:46 2. Exception is hudson.AbortException: script returned exit code 2
17:14:46 [Pipeline] echo
17:14:46 3. finally
17:14:46 [Pipeline] }
17:14:46 [Pipeline] // node
17:14:46 [Pipeline] End of Pipeline
17:14:47 Finished: SUCCESS

相关文章

网友评论

      本文标题:pipeline demo

      本文链接:https://www.haomeiwen.com/subject/mmfjoltx.html