Scenario: Trigger a job when commit is pushed and the pusher is not named "build".
Given the following generic variables are configured:
| variable | expression | expressionType | defaultValue | regexpFilter |
| user | $.pusher.name | JSONPath | | |
Given filter is configured with:
| text | expression |
| $user | ^((?!build)) |
Given received post content is:
"""
{
"pusher": {
"name": "baxterthehacker",
}
}
"""
Then the job is triggered
Given received post content is:
"""
{
"pusher": {
"name": "build",
}
}
"""
Then the job is not triggered
3 回答
通常,Jenkins使用a (non-Jenkinsfile) refspec like refs/tags/*触发构建
因此,为了避免这种情况,您可以指定
refs/heads/*
(作为seen here)或check issue 507并取消选中"lightweight checkout"以避免获取标记 .我假设您使用的是Multibranch Pipeline或GitHub / Bitbucket组织 .
您可以在分支源配置下抑制所有或指定分支的自动SCM触发 .
您可以使用Generic Webhook Trigger Plugin执行此操作 .
有许多替代品,如:
如果提交消息具有特殊格式,则不触发 .
如果特定用户推送提交,则不会触发 . 就像Jenkins中使用的特殊用户一样 .
从其中一个测试用例: