Jenkins git 提交通知配置
Jenkins git commit notification configuration
我使用 gitlab 中的 How to configure Git post commit hook 来通知 Jenkins 有新的提交,例如:
https://jenkins.company.com/git/notifyCommit?url=project:Project.git
效果很好。
但是,如果测试用例在 master branch
上没有失败,我想发布一个新版本(git 标记并更改文件中的某些版本 & push). 这会重新触发上述 webhook。
是否可以让 Jenkins 仅在特定用户构建时才重新触发构建?
目前这将是我们的解决方案
阶段'Checkout'
结帐单片机
回声 "My branch is: ${env.BRANCH_NAME}"
回声 "GIT commit is:"
sh ' git log -1'
// Jenkins 没有更好地支持它:https://issues.jenkins-ci.org/browse/JENKINS-26133
嘘 'git log -1 --pretty=%aE > commandResult'
结果 = readFile('commandResult').trim()
如果("jenkins@faktorzehn.at" == 结果){
回声 'STOP pipeline to prevent infinite loop'
错误 'STOP to prevent infinite loop'
}
也许你应该把开发分支和主分支分开? IE。让开发人员推送提交到 develop
,设置 Jenkins 构建 develop
并在测试后推送到 master
。这样你就不会在构建循环中结束(并且单独的分支将使使用测试代码更容易)。
我使用 gitlab 中的 How to configure Git post commit hook 来通知 Jenkins 有新的提交,例如:
https://jenkins.company.com/git/notifyCommit?url=project:Project.git
效果很好。
但是,如果测试用例在 master branch
上没有失败,我想发布一个新版本(git 标记并更改文件中的某些版本 & push). 这会重新触发上述 webhook。
是否可以让 Jenkins 仅在特定用户构建时才重新触发构建?
目前这将是我们的解决方案
阶段'Checkout' 结帐单片机 回声 "My branch is: ${env.BRANCH_NAME}" 回声 "GIT commit is:" sh ' git log -1' // Jenkins 没有更好地支持它:https://issues.jenkins-ci.org/browse/JENKINS-26133 嘘 'git log -1 --pretty=%aE > commandResult' 结果 = readFile('commandResult').trim() 如果("jenkins@faktorzehn.at" == 结果){ 回声 'STOP pipeline to prevent infinite loop' 错误 'STOP to prevent infinite loop' }
也许你应该把开发分支和主分支分开? IE。让开发人员推送提交到 develop
,设置 Jenkins 构建 develop
并在测试后推送到 master
。这样你就不会在构建循环中结束(并且单独的分支将使使用测试代码更容易)。