且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Jenkins声明性语法登录Docker?

更新时间:2023-12-04 18:46:52

您可以将script {}块用作声明性步骤,以包装仅在脚本管道中运行的所有内容.例如(未试用)

You can use a script {} block as a declarative step to wrap anything that would otherwise only run in scripted pipelines. e.g. (untested)

stages {
    stage('Example') {
        steps {
            script {
                docker.withRegistry('https://registry.example.com', 'credentials-id') {

                    def customImage = docker.build("my-image:${env.BUILD_ID}")

                    /* Push the container to the custom Registry */
                    customImage.push()
                }
            }
        }
    }
}