Jenkins pipeline not honoring agent specification

久未见 提交于 2019-12-13 03:18:34

问题


At the pipeline level I specify the agent and node (with both the label and custom workspace). When the pipeline kicks off it runs on the specified node, but when it hits the 'build job' picks the first available node. I tried playing with the NodeLabel plugin, but that didn't work either.

This is my Jenkinsfile:

pipeline {
    agent {
       node {
            label "Make Build Server"
            customWorkspace "$Workspace"
       }
    }
    options {
       skipDefaultCheckout()
    }
    stages {
        stage('PreBuild'){
            steps{
                input 'Did you authenticate the server through all the firewalls?'
            }
        }
        stage('Housekeeping'){
            steps{
                build job: 'Housekeeping'
            }
        }
    }
}

回答1:


When you use the build instruction in a Jenkinsfile, it's telling jenkins you want to build a completely separate job. It is that other job that will need to specify on what agent it will build. If it's a job based on a Jenkinsfile, then that other Jenkinsfile will indicate the agent. If it is a freestyle job, likewise. So the thing you were expecting--that the other job build on the agent you specified in the "parent Jenkinsfile"--is reasonable, but is not the way it works.

Hope this helps!



来源:https://stackoverflow.com/questions/46614297/jenkins-pipeline-not-honoring-agent-specification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!