如何在詹金斯管道中覆盖代理

时间:2018-10-15 14:02:02

标签: jenkins

我的目标是创建一个管道,其中每个阶段除一个阶段(以下示例中的阶段E)外,都具有相同的代理。

pipeline {
    agent {
        dockerfile {
            filename 'Dockerfile.tester'
            args '-v $HOME/.docker:/root/.docker'
        }
    }
    stages {
        stage('A') { ... }
        stage('B') { ... }
        stage('C') { ... }
        stage('D') { ... }
        stage('E') {
            agent {
                dockerfile {
                    filename 'Dockerfile.deploy'
                    args '-v $HOME/.docker:/root/.docker'
                }
            }
        }
        stage('F') { ... }
    }
}

到目前为止,我能做的是将代理全局设置为无,然后将每个阶段的代理Dockerfile.tester设置为1,并将另外1个阶段的代理设置为Dockerfile.deploy。知道如何在全局设置一次然后覆盖它吗?

如果我像上面那样做,这里是新错误:

> git rev-parse --is-inside-work-tree # timeout=10

Fetching changes from the remote Git repository

 > git config remote.origin.url https://bitbucket.org/*********/*********.git # timeout=10

Cleaning workspace

 > git rev-parse --verify HEAD # timeout=10

Resetting working tree

 > git reset --hard # timeout=10

 > git clean -fdx # timeout=10

Fetching without tags

Fetching upstream changes from https://bitbucket.org/*********/*********.git

 > git --version # timeout=10

using GIT_ASKPASS to set credentials BitBucket Login for checkout / pushing

 > git fetch --no-tags --progress https://bitbucket.org/*********/********.git +refs/heads/dev:refs/remotes/origin/dev

Checking out Revision ab0d4a522d872a129f53a74f6ecadafb8fd82f11 (dev)

 > git config core.sparsecheckout # timeout=10

 > git checkout -f ab0d4a522d872a129f53a74f6ecadafb8fd82f11

Commit message: "chore: test"

Cleaning workspace

 > git rev-parse --verify HEAD # timeout=10

Resetting working tree

 > git reset --hard # timeout=10

 > git clean -fdx # timeout=10

[Bitbucket] Notifying commit build result

docker login failed

0 个答案:

没有答案