詹金斯工作如何要求两个或多个标签? [英] How to require two or more labels for a jenkins job?

查看:62
本文介绍了詹金斯工作如何要求两个或多个标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道Jenkins的名为限制在何处可以运行该项目"的选项似乎只允许在标签表达式"字段中使用单个值.

I don't know how it happens that the option named "Restrict where this project can be run" from Jenkins seems to allow only a single value inside "Label Expression" field.

为了添加多个标签,我尝试了多种组合,但找不到任何方法放置两个标签.

I tried lots of combinations in order to add more than one label and I wasn't able to find any way to put two.

我需要提及的是,这些标签之间需要AND.

I need to mention that I need AND between these labels.

具有讽刺意味的是,此选项甚至具有一个Info按钮,该按钮加载了一些文档,但缺少说明表达式的外观.Jenkins UX棺材中的另一个小钉子.在这一方面,谷歌都没有提供帮助.

The irony is that this option even has an Info button which loads some documentations, which is missing to say how an expression is supposed to look like. Another small nail in the Jenkins UX coffin. On this one neither Google helped.

推荐答案

有一个詹金斯错误,导致不显示帮助文本.自1.585开始存在,自1.621起固定存在(或分别为1.609.3).

There is a Jenkins bug causing the help text not to be shown. It is present since 1.585 and fixed since 1.621 (or 1.609.3 respectively).

以下是帮助文字:

如果要始终在特定节点/从属上运行此项目,只需指定其名称即可.当节点数量较少时,此方法效果很好.

If you want to always run this project on a specific node/slave, just specify its name. This works well when you have a small number of nodes.

随着集群规模的增长,不要将项目绑定到特定的从服务器变得很有用,因为当从服务器来回移动时,这会损害资源利用率.对于这种情况,请为从站分配标签以对其功能和特征进行分类,并在这些标签上指定布尔表达式以决定在哪里运行.

As the size of the cluster grows, it becomes useful not to tie projects to specific slaves, as it hurts resource utilization when slaves may come and go. For such situation, assign labels to slaves to classify their capabilities and characteristics, and specify a boolean expression over those labels to decide where to run.

有效运算符

按优先级支持以下运算符.

The following operators are supported, in the order of precedence.

(expr)括号

!expr 否定

expr& expr

expr || expr

a->b 暗示"操作员.等同于!a | b .例如,可以将 windows-> x64 认为是如果在Windows从站上运行,则该从站必须为64位."它仍然允许Jenkins在Linux上运行此构建.

a -> b "implies" operator. Equivalent to !a|b. For example, windows->x64 could be thought of as "if run on a Windows slave, that slave must be 64bit." It still allows Jenkins to run this build on linux.

a<->b 仅当且仅当"操作员.等同于 a&&b ||!a&!b .例如,可以将 windows<-> sfbay 视为如果在Windows从属服务器上运行,则该从属服务器必须位于SF托架区域,但如果不在Windows上,则必须位于SF托架区域.在海湾地区."

a <-> b "if and only if" operator. Equivalent to a&&b || !a&&!b. For example, windows<->sfbay could be thought of as "if run on a Windows slave, that slave must be in the SF bay area, but if not on Windows, it must not be in the bay area."

所有运算符都是左关联的(即 a-> b-> c<->(a-&b; b)-> c )表达式可以包含空格以获得更好的可读性,它将被忽略.

All operators are left-associative (i.e., a->b->c <-> (a->b)->c ) An expression can contain whitespace for better readability, and it'll be ignored.

如果标签名称或从属名称包含不安全的字符,则可以使用引号.例如,"jenkins-solaris(Solaris)"||"Windows 2008"

Label names or slave names can be quoted if they contain unsafe characters. For example, "jenkins-solaris (Solaris)" || "Windows 2008"

这篇关于詹金斯工作如何要求两个或多个标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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