我试图在Jenkins中完成以下任务:1)构建maven项目2)运行测试用例时,我将某些消息打印到控制台输出3)解析构建的控制台输出并确定输出中是否存在某些模式4)如果模式存在,我想用特定的字符串标记构建
我已经完成了步骤1-3。我无法创建动态标签并将其绑定到构建。我有一个Groovy脚本,它解析控制台输出并确定模型是否存在于构建的输出中。
Bamboo提供此功能以基于构建的控制台输出中存在的正则表达式标记构建。链接 - https://confluence.atlassian.com/bamboo0606/using-bamboo/jobs-and-tasks/configuring-jobs/configuring-miscellaneous-settings-for-a-job/configuring-automatic-labeling-of-job-build-results
我已经浏览了各种现有的Jenkins插件,但尚未成功实现此功能。是否有插件来实现此功能,或者我可以在Groovy脚本中添加其他行来创建动态构建标签。任何帮助表示赞赏。
你可以使用if
设置代理:
def AGENT_LABEL = null
node('master') {
stage('Checkout and set agent'){
checkout scm
### Or just use any other approach to figure out agent label: read file, etc
if (env.BRANCH_NAME == 'master') {
AGENT_LABEL = "prod"
} else {
AGENT_LABEL = "dev"
}
}
}
pipeline {
agent {
label "${AGENT_LABEL}"
}