pipeline class 使用

2021-10-12  本文已影响0人  AppleLin_cdea

2021年10月12日20:58:29 星期二
pipeline 如何使用 class 例子

示例代码

import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException

class CDemo  implements Serializable
{
    def script
    def m_is_cov
    def CDemo(sci)
    {
        this.script = sci
    }
    
    def set(is_cov=false)
    {
        m_is_cov = is_cov
        script.echo "m_is_cov is "+m_is_cov
    }
}

node('general')
{
    stage('cov') {
        obj = new CDemo(this)
        obj.set(true)
        obj.set(false)
    }
}

运行结果

Console Output
21:04:00 Started by user Apple
21:04:00 Running in Durability level: MAX_SURVIVABILITY
21:04:00 [Pipeline] Start of Pipeline
21:04:00 [Pipeline] node
21:04:00 Running on general in /home/jenkins/workspace/demo
21:04:00 [Pipeline] {
21:04:00 [Pipeline] stage
21:04:00 [Pipeline] { (cov)
21:04:00 [Pipeline] echo
21:04:00 m_is_cov is true
21:04:01 [Pipeline] echo
21:04:01 m_is_cov is false
21:04:01 [Pipeline] }
21:04:01 [Pipeline] // stage
21:04:01 [Pipeline] }
21:04:01 [Pipeline] // node
21:04:01 [Pipeline] End of Pipeline
21:04:02 Finished: SUCCESS

总结类

上一篇下一篇

猜你喜欢

热点阅读