i want to trigger my jenkins job when a Merge Request if merged to a specific branch is a particular folder in the local machine?

huangapple go评论56阅读模式
英文:

i want to trigger my jenkins job when a Merge Request if merged to a specific branch is a particular folder in the local machine?

问题

在Jenkins中,我如何配置一个Jenkins任务,当我的GitLab帐户上有一个合并请求(mr)被合并时,或者当我将本地分支合并到主分支或任何指定的分支时,该任务会被触发,并且当合并请求被拉取到我的本地主分支或特定文件夹中时也会触发?

英文:

In Jenkins how can I configure a Jenkins job which is triggered when I have an mr which is merged on my GitLab account, is pulled to my master branch locally, or in that specific folder when I merge a local branch to master or any specified branch???

答案1

得分: 0

我怀疑你会找到一种手动指定Jenkins作业触发器的所有条件的方法。然而,有一种有效的方法可以实现这一点。

您需要创建一个作业,每次提交时都运行。在作业内,定义一个阶段,并指定所有上述条件。如果满足任何条件,则将构建作业触发为下游作业。

为了找出哪些文件已更改,您可以使用git diff来执行最新提交和之前提交之间的差异。分支名称可作为内置变量env.BRANCH_NAME获得。

英文:

I doubt you will find a way to manually specify all these conditions for a trigger in a Jenkins job. However, there is an effective way to achieve this.

You need to create a job that runs every time a commit is made. Within the job, define a stage and specify all of your above conditions. If any of the conditions are met, trigger your build job as a downstream job.

In order to find which files had been changed you can use git diff to perform a diff between your latest commit, and the commit before that. The branch name is available as an in-built variable env.BRANCH_NAME.

huangapple
  • 本文由 发表于 2023年5月29日 12:59:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76354775.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定