Jenkins似乎构建了未构建的分支,而不是GitHub post commit钩子上指定的分支。我如何告诉Jenkins构建GitHub后提交钩子中指定的分支 - 即使它之前已经构建了它?
例如,让我们假设开发分支是20个提交功能/酷,功能/酷在git哈希123abc,现在我合并开发,开发和功能/酷在git哈希123abc。同时,feature / irrelevant具有新提交,因此任何分支上的最新提交都是功能/不相关的。我将开发分支推送到GitHub,Jenkins构建功能/不相关而不是开发。
GitHub设置为通过post-commit hook触发Jenkins,并且在提交给GitHub时,Jenkins确实被触发了。我已经将post-commit挂钩发送到runscope并验证了有效负载具有正确的git散列和分支名称。
Jenkins设置构建存储库URL git@github.mygithubenterpriseurl.com:user/project.git
和所有分支(Branch Specifier = **
)所有其他Jenkins SCM设置都是默认设置。
在构建中,我看到以下几行:
Fetching upstream changes from git@github.mygithubenterpriseurl.com:user/project.git
getCandidateRevisions(false,null,,,,remoteUrls=[git@github.mygithubenterpriseurl.com:user/project.git],buildsByBranchName={...snip...},lastBuild=Build #742 of Revision bd40a4956b3f1b6a70552b86bfd6df9a7226dca3 (origin/feature/irrelevant)]) considering branches to build
Seen branch in repository origin/develop
Seen branch in repository origin/master
Seen branch in repository origin/feature/coolness
Seen branch in repository origin/feature/irrelevant
Seen branch in repository origin/release/name
Seen 7 remote branches
Starting with all the branches: [...snip...}
After filtering out what's already been built: [Revision e6a90ad3fa4c02864f36647d77db43721b991992 (origin/feature/irrelevant)]
Checking out Revision e6a90ad3fa4c02864f36647d77db43721b991992 (origin/feature/irrelevant)
一旦进入我的构建脚本,我就会回复$GIT_HASH
和$GIT_BRANCH
,并得到错误的内容:GIT_HASH=e6a90ad3fa4c02864f36647d77db43721b991992
和GIT_BRANCH=origin/feature/irrelevant
完成后,它会构建最新的提交,而不是git hash上指定的提交。
Jenkins是v.1.551,我的已安装和有效的Jenkins插件和版本列表:
active-directory: 1.24
analysis-core: 1.56
ansicolor: 0.3.1
ant: 1.2
build-flow-plugin: 0.10
buildgraph-view: 1.1.1
cobertura: 1.9.5
conditional-buildstep: 1.3.3
config-file-provider: 2.7.4
copy-to-slave: 1.4.3
credentials: 1.10
cvs: 2.11
envfile: 1.2
envinject: 1.89
external-monitor-job: 1.2
ezwall: 0.2
findbugs: 4.56
git-client: 1.8.0
git-parameter: 0.2
git: 2.2.1
github-api: 1.44
github-oauth: 0.14
github: 1.8
ivy: 1.23.2
javadoc: 1.1
jobConfigHistory: 2.6
ldap: 1.8
logstash: 0.8.0
mailer: 1.8
matrix-auth: 1.2
maven-plugin: 2.2
monitoring: 1.50.0
notification: 1.5
nunit: 0.15
pam-auth: 1.1
parameterized-trigger: 2.24
postbuildscript: 0.16
publish-over-ssh: 1.11
pwauth: 0.4
role-strategy: 2.1.0
run-condition: 1.0
scm-api: 0.2
scp: 1.8
sonar: 2.1
ssh-credentials: 1.6.1
ssh-slaves: 1.6
ssh: 2.4
subversion: 2.2
testng-plugin: 1.6
token-macro: 1.10
translation: 1.11
vsphere-cloud: 1.1.6
windows-slaves: 1.0
xunit: 1.84
答案 0 :(得分:2)
看来此功能不存在。建议添加https://issues.jenkins-ci.org/browse/JENKINS-24291是一个问题。 https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/com/cloudbees/jenkins/GitHubWebHook.java#L175专门从webhook中提取存储库URL和提交者名称,并丢弃其余数据...包括git hash。
答案 1 :(得分:0)
不会拉请求做你想要的吗?如果构建成功,则测试pull请求/合并并实际提交并推送它