带有标签或节点调用从节点的 Jenkins 管道代理?
Jenkins pipeline agent with label or node call slave node?
有人问如何创建代理并创建从节点(),我不知道是否正确:
agent {
label 'my-defined-label'
}
和
agent {
node {
label 'my-defined-label'
customWorkspace '/some/other/path'
}
}
所以 'my-defined-label' 只是奴隶的名字?
感谢您的回答
它可以匹配确切的节点名称、标签、任何其他支持的标签表达式。例如,java8 && linux
、(docker || java) && !windows
和 corp-agent-node-01-name
都是有效的标签语法。
documentation 清楚内置语法的工作原理:
Allocates an executor on a node (typically a slave) and runs further code in the context of a workspace on that slave.
label
- Computer name, label name, or any other label expression like linux && 64bit
to restrict where this step builds. May be left blank, in which case any available executor is taken.
Valid Operators
The following operators are supported, in the order of precedence.
(expr) - parenthesis
!expr - negation
expr&&expr - and
expr||expr - or
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 - "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."
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.
Label names or slave names can be quoted if they contain unsafe characters. For example, "jenkins-solaris (Solaris)" || "Windows 2008"
有人问如何创建代理并创建从节点(
agent {
label 'my-defined-label'
}
和
agent {
node {
label 'my-defined-label'
customWorkspace '/some/other/path'
}
}
所以 'my-defined-label' 只是奴隶的名字?
感谢您的回答
它可以匹配确切的节点名称、标签、任何其他支持的标签表达式。例如,java8 && linux
、(docker || java) && !windows
和 corp-agent-node-01-name
都是有效的标签语法。
documentation 清楚内置语法的工作原理:
Allocates an executor on a node (typically a slave) and runs further code in the context of a workspace on that slave.
label
- Computer name, label name, or any other label expression likelinux && 64bit
to restrict where this step builds. May be left blank, in which case any available executor is taken.Valid Operators
The following operators are supported, in the order of precedence.
(expr) - parenthesis
!expr - negation
expr&&expr - and
expr||expr - or
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 - "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."
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.
Label names or slave names can be quoted if they contain unsafe characters. For example, "jenkins-solaris (Solaris)" || "Windows 2008"