gpt4 book ai didi

git - 在 GitHub 上触发 Jenkins 作业推送到特定分支

转载 作者:行者123 更新时间:2023-12-04 14:10:37 25 4
gpt4 key购买 nike

我正在尝试基于对某个分支的 GitHub PUSH 触发作业。

我设置了一个 webhook 到 JENKINS_URL/git/notifyCommit?url=REPO_URLPoll SCM没有时间表。

每个 push 都会触发作业但我无法过滤掉分支 - 我希望它只在推送到 master 时发生。

最佳答案

为此,您必须使用 git hook。

git hook 获取分支名称作为参数。

Hook code

#!/bin/sh

while read oldrev newrev refname
do
branch=`echo $refname | cut -d'/' -f3`

###
# Do whatever you want to do here with the branch name
###

done

关于git - 在 GitHub 上触发 Jenkins 作业推送到特定分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37099696/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com