Reputation: 14383
I setup Jenkins with a Parent and Child job. Parent job is configured to execute on pull request and Child job is triggered by Parent job.
My parent job configuration,
Under Source Code Management section,
Repository URL: https://github.com/myorg/myrepo.git
Name: origin
Refspec: +refs/pull/*:refs/remotes/origin/pr/*
Branch Specifier (blank for default): ${sha1}
Under Build section,
Trigger/call builds on other projects :
Current build parameters
Pass-through Git Commit that was built
My child job configuration,
Under Source Code Management section,
Repository URL: https://github.com/myorg/myrepo.git
Name: blank
Refspec: blank
Branch Specifier (blank for default): blank
Problem:
I get an error when the child job gets executed,
Parent job console,
00:00:00.249 Last Built Revision: Revision defghi (origin/pr/29/merge)
00:00:00.407 Fetching upstream changes from https://github.com/myorg/myrepo.git
00:00:02.237 Commencing build of Revision abcdef (origin/pr/28/merge)
00:00:02.247 Checking out Revision abcdef (origin/pr/28/merge)
00:00:02.843 Waiting for the completion of child
00:01:30.776 child #23 completed. Result was FAILURE
Child job console,
00:00:00.000 Started by upstream project "parent" build number 19
00:00:00.002 originally caused by:
00:00:00.002 GitHub pull request #28 of commit cdefgh automatically merged.
00:00:00.136 Last Built Revision: Revision bcdefg (detached)
00:00:01.101 Commencing build of Revision abcdef (detached)
00:00:01.151 Checking out Revision abcdef (detached)
00:00:01.317 FATAL: Could not checkout null with start point abcdef
00:00:01.317 hudson.plugins.git.GitException: Could not checkout null with start point abcdef
00:00:01.317 at hudson.plugins.git.GitAPI.checkoutBranch(GitAPI.java:863)
00:00:01.317 at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1192)
00:00:01.317 at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1176)
00:00:01.317 at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2394)
00:00:01.317 at hudson.remoting.UserRequest.perform(UserRequest.java:118)
00:00:01.317 at hudson.remoting.UserRequest.perform(UserRequest.java:48)
00:00:01.317 at hudson.remoting.Request$2.run(Request.java:326)
00:00:01.317 at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
00:00:01.317 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
00:00:01.317 at java.util.concurrent.FutureTask.run(FutureTask.java:138)
00:00:01.317 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
00:00:01.317 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
00:00:01.317 at java.lang.Thread.run(Thread.java:619)
00:00:01.317 Caused by: hudson.plugins.git.GitException: Error performing command: /usr/bin/git checkout -f abcdef
00:00:01.317 Command "/usr/bin/git checkout -f abcdef" returned status code 128: fatal: reference is not a tree: abcdef
Any idea how to resolve this ?
Upvotes: 3
Views: 1311
Reputation: 957
You need to specify the refspec (+refs/pull/:refs/remotes/origin/pr/) and the branch specifier (${sha1}) for the child project as well.
Upvotes: 1