詹金斯管道不遵守代理规范 [英] Jenkins pipeline not honoring agent specification

查看:75
本文介绍了詹金斯管道不遵守代理规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在管道级别,我指定代理和节点(带有标签和自定义工作区).管道启动时,它将在指定的节点上运行,但是当命中"build job"时,将选择第一个可用节点.我尝试过使用NodeLabel插件,但是那也不起作用.

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.

这是我的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'
            }
        }
    }
}

推荐答案

在Jenkins文件中使用build指令时,它告诉jenkins您想要构建一个完全独立的作业. 该其他作业将需要指定将在哪个代理上构建.如果这是基于Jenkinsfile的作业,则其他Jenkinsfile将指示代理.如果是自由式工作,则同样.因此,您期望的事情-另一个工作建立在您在父Jenkinsfile"中指定的代理上进行-是合理的,但不是它的工作方式.

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.

希望这会有所帮助!

这篇关于詹金斯管道不遵守代理规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆