Is there a way to move the entire post {} build section in Jenkinsfile to the global pipeline library?

天大地大妈咪最大 提交于 2019-12-06 01:36:53

I am not entirely if this will work as I don't use declarative pipelines, so am unsure how rigid the top level structure is. But I would revert to a script block.

@Library('jenkins-shared-library')_
pipeline {
    agent none
    stages {
        stage ('System Info') { agent any
            steps { printSysInfo() }
        }

        stage ('Init'){ agent {label 'WinZipSE'}
            steps { init('SCMroot') }
        }
        stage('Build') { agent any 
            steps { doMagic() }
        }
    }

    // This entire 'post {}' section needs to go to a shared lib
    // and be called just with a simple methed call, e.g.
    // doPostBuild()
    script {
        doPostBuild()
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!