我可以在声明式Jenkins管道中定义多个代理标签吗? [英] Can I define multiple agent labels in a declarative Jenkins Pipeline?

查看:838
本文介绍了我可以在声明式Jenkins管道中定义多个代理标签吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用声明性的Jenkins管道运行部分我的构建管道,并想知道是否可以定义多个代理标签。



我有一些建立代理连接到我的詹金斯,并希望这个特定的管道能够由具有不同标签的各种代理商(但不是由所有代理商)构建。更具体地说,假设我有2个带有标签的代理商'小',4个标签'中',6个标签'大'。现在我有一个资源非常低的管道,我希望它只在一个'小'或'中等'大小的代理上执行,但不是大规模的代理,因为它可能会导致更大的构建在队列中等待不必要很长时间。

到目前为止,我见过的所有例子都只使用一个标签。
我试过这样的事情:

 代理人{label'small,medium'} 

但它失败了。

我使用的是Jenkins 2.5 Pipeline Plugin。

解决方案

您可以在Jenkins安装中看到'Pipeline-syntax'帮助并查看示例步骤node参考。

您可以使用 exprA || exprB

 node('small || medium'){
//一些区块
}


I'm using declarative Jenkins pipelines to run some of my build pipelines and was wondering if it is possible to define multiple agent labels.

I have a number of build agents hooked up to my Jenkins and would like for this specific pipeline to be able to be built by various agents that have different labels (but not by ALL agents).

To be more concrete, let's say I have 2 agents with a label 'small', 4 with label 'medium' and 6 with label 'large'. Now I have a pipeline that is very resource-low and I want it to be executed on only a 'small'- or 'medium'-sized agent, but not on a large one as it may cause larger builds to wait in the queue for an unnecessarily long time.

All the examples I've seen so far only use one single label. I tried something like this:

 agent { label 'small, medium' }

But it failed.

I'm using version 2.5 of the Jenkins Pipeline Plugin.

解决方案

You can see the 'Pipeline-syntax' help within your Jenkins installation and see the sample step "node" reference.

You can use exprA||exprB:

node('small||medium') {
    // some block
}

这篇关于我可以在声明式Jenkins管道中定义多个代理标签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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