简体   繁体   English

基于新的 GitHub 版本触发 Jenkins 构建或提交到 master 分支

[英]Trigger Jenkins build based on a new GitHub release or commit to the master branch

I realize this question has been asked before here , here , and here , but none of these solutions appears to be working for my Jenkins setup and I can't figure out why.我意识到这里这里这里之前已经问过这个问题,但是这些解决方案似乎都不适用于我的 Jenkins 设置,我不知道为什么。

My objective is to trigger a Jenkins build when either a new commit is made to the master branch or when any tag (or in GitHub, a release) is added to the repo.我的目标是在对master分支进行新提交或将任何标记(或在 GitHub 中,发布)添加到 repo 时触发 Jenkins 构建。 Here's my current setup:这是我目前的设置:

在此处输入图片说明

When I make a new commit to the master branch, a new build is triggered.当我对master分支进行新的提交时,会触发一个新的构建。 But when I add a new GitHub release, nothing happens.但是当我添加一个新的 GitHub 版本时,什么也没有发生。

Looking at my "Git Polling Log" shows the following output:查看我的“Git 轮询日志”显示以下输出:

Started on Jun 20, 2017 1:25:00 AM
Polling SCM changes on master
Using strategy: Default
[poll] Last Built Revision: Revision 035c0f46422616b1862376b79c43b2562dc66f93 (origin/master)
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repositories
 > git config remote.origin.url git@github.com:some-org/sample-app-frontend.git # timeout=10
Fetching upstream changes from git@github.com:some-org/sample-app-frontend.git
 > git --version # timeout=10
using GIT_SSH to set credentials GitHub SSH Key
 > git fetch --tags --progress git@github.com:some-org/sample-app-frontend.git +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/remotes/origin/tags/*
Polling for changes in
Seen branch in repository origin/master
Seen branch in repository origin/tags/stage-v0.0.1
Seen branch in repository origin/tags/stage-v0.0.2
Seen branch in repository origin/tags/stage-v0.0.3
Seen branch in repository origin/tags/v0.0.4
Seen branch in repository origin/tags/v0.0.5
Seen branch in repository origin/tags/v0.0.6
Seen branch in repository origin/tags/v0.0.7
Seen 8 remote branches
 > git tag -l # timeout=10
 > git rev-parse refs/tags/stage-v0.0.2^{commit} # timeout=10
 > git rev-parse refs/tags/v0.0.7^{commit} # timeout=10
 > git rev-parse refs/tags/stage-v0.0.1^{commit} # timeout=10
 > git rev-parse refs/tags/v0.0.6^{commit} # timeout=10
 > git rev-parse refs/tags/v0.0.5^{commit} # timeout=10
 > git rev-parse refs/tags/v0.0.4^{commit} # timeout=10
 > git rev-parse refs/tags/stage-v0.0.3^{commit} # timeout=10
Done. Took 0.2 sec
No changes

Note that I'm using git polling once per minute.请注意,我每分钟使用一次 git 轮询。 So it appears that git correctly detects the new branches, but somehow the git polling Jenkins is doing does not think a new branch qualifies as a "change" since it keeps reporting "No changes" at the bottom.所以看起来 git 正确地检测到新分支,但不知何故,詹金斯正在做的 git 轮询并不认为新分支有资格作为“更改”,因为它一直在底部报告“无更改”。

I have searched on this for sometime and was able to figure out the solution for triggering the jenkins job when tag is released from git hub.我已经搜索了一段时间,并且能够找出在从 git hub 释放标签时触发 jenkins 作业的解决方案。 Here is the screenshot.这是屏幕截图。 Select advanced option from where git repositories are given and configure the details as below.从提供 git 存储库的位置选择高级选项并配置如下详细信息。 So when release is tagged the jenkins job is triggered.因此,当发布被标记时,jenkins 作业被触发。

Refspec value should be +refs/tags/*:refs/remotes/tags/* . Refspec值应该是+refs/tags/*:refs/remotes/tags/*

在此处输入图片说明

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

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