[英]Build on openshift with a Jenkins pipeline referring to a git branch
I have the following structure: 我有以下结构:
Versions: 版本:
What I'm able to do: make a push on dev/master that start the 2 pipelines and builds the two branches. 我能做的是:推动dev / master来启动2个管道并建立两个分支。 There starts two build because I don't know how to filter out that a push/merge event is made on dev or master. 因为我不知道如何过滤在dev或master上进行的push / merge事件,所以开始两个构建。 I want to do this because: 我想要这样做是因为:
I saw two option to resolve this. 我看到了两种解决方案。 On Gitlab there are no possibility to drive the webhook event on a defined branch. 在Gitlab上,不可能在已定义的分支上驱动webhook事件。 (or is there and I don't know how?) On the pipeline I could write some code to check on witch branch there is made a push/merge. (或者在那里,我不知道如何?)在管道上,我可以编写一些代码来检查女巫分支,是否进行了推/合并。 But I don't know how exactly make this check. 但是我不知道如何进行这项检查。
Are there other options? 还有其他选择吗? If possible I don't want to change the workflow, but I'm open to hear any good Idea. 如果可能的话,我不想更改工作流程,但是我愿意听到任何好的建议。
If I'm missing some relevant information please ask me. 如果我缺少一些相关信息,请询问我。 I don't publish any code because the context are very big, and principally I only need the right direction or some ideas how to solve this. 我不发布任何代码,因为上下文非常大,原则上我只需要正确的方向或一些解决方案。
So At the end I found a way by myself. 所以最后我自己找到了一种方法。
I think it's not elegant but at the moment it solves my problem. 我认为它并不优雅,但目前可以解决我的问题。
All I do is to check with git in the pipeline the hash of the last Merge and the last hash of the branch in this way: 我要做的就是以这种方式在管道中使用git检查最后一个Merge和分支的最后一个哈希:
def lastMerge = sh(returnStdout: true, script: 'git show :/^Merge --pretty=format:"%H"').trim()
def hash = sh(returnStdout: true, script: 'git log -1 origin/master --pretty=format:"%H"').trim()
if(lastMerge==hash){
doTheJob()
}
If there are better solutions, I'm open to hear it. 如果有更好的解决方案,我很乐意听。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.