简体   繁体   English

Jenkins git commit通知配置

[英]Jenkins git commit notification configuration

I use How to configure Git post commit hook from gitlab to notify Jenkins of a new commit like: 我使用了如何从gitlab 配置Git发布提交钩子来通知Jenkins像这样的新提交:

https://jenkins.company.com/git/notifyCommit?url=project:Project.git

which works just fine. 效果很好。

However, if the test cases do not fail on master branch I want to release a new version (git tag & change some version in a file & push ). 但是,如果测试用例在master branch上没有失败,我想发布一个新版本(git标签并在file和push中更改某个版本)。 This re-triggers the aforementioned webhook. 这将重新触发上述的webhook。

Is it possible to have Jenkins only re-trigger the build if built by a certain user? Jenkins是否可以仅由特定用户重新触发构建?

For now this will be our solution 目前,这将是我们的解决方案

stage 'Checkout' checkout scm echo "My branch is: ${env.BRANCH_NAME}" echo "GIT commit is:" sh ' git log -1' // Jenkins does not support it any better: https://issues.jenkins-ci.org/browse/JENKINS-26133 sh 'git log -1 --pretty=%aE > commandResult' result = readFile('commandResult').trim() if("jenkins@faktorzehn.at" == result){ echo 'STOP pipeline to prevent infinite loop' error 'STOP to prevent infinite loop' } 阶段'Checkout'checkout scm echo“我的分支是:$ {env.BRANCH_NAME}” echo“ GIT commit是:” sh'git log -1'// Jenkins不再支持它: https://issues.jenkins -ci.org/browse/JENKINS-26133 sh'git log -1 --pretty =%aE> commandResult'结果= readFile('commandResult')。trim()if(“ jenkins@faktorzehn.at” ==结果) {echo'停止管道以防止无限循环'错误'停止以防止无限循环'}

Maybe you should separate the development branch and the master branch? 也许您应该将开发分支和主分支分开? Ie have developer push commits to develop , set Jenkins to build develop and push to master after testing. 即有开发商推致力于develop ,设置詹金斯建设develop和推到master测试后。 This way you should not end up in a build loop (and the separate branch will make it easier to work with tested code). 这样,您不应该最终陷入构建循环中(并且单独的分支将使使用经过测试的代码更容易)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM