All,
I’m having some trouble with getting PR jobs to run correctly. I’ve tried making a simple PR to illustrate my problem. First, here’s the output of our build server:
09:45:05 GitHub pull request #17 of commit e22a0f7053c41cc2b791ff63b7ccd11c356b34f6, no merge conflicts.
09:45:05 Setting status of e22a0f7053c41cc2b791ff63b7ccd11c356b34f6 to PENDING with url <redacted>/job/Ipr__robot_localization__ubuntu_trusty_amd64/2/ and message: 'Build started sha1 is merged.'
09:45:05 Using context: Ipr__robot_localization__ubuntu_trusty_amd64
09:45:05 Building remotely on <redacted> (swarm buildslave) in workspace /home/jenkins-slave/workspace/Ipr__robot_localization__ubuntu_trusty_amd64
09:45:05 Cloning the remote Git repository
09:45:05 Using shallow clone
09:45:05 Cloning repository https://github.com/locusrobotics/robot_localization.git
09:45:05 > git init /home/jenkins-slave/workspace/Ipr__robot_localization__ubuntu_trusty_amd64/catkin_workspace/src/robot_localization # timeout=10
09:45:06 Fetching upstream changes from https://github.com/locusrobotics/robot_localization.git
09:45:06 > git --version # timeout=10
09:45:06 > git -c core.askpass=true fetch --tags --progress https://github.com/locusrobotics/robot_localization.git +refs/heads/*:refs/remotes/origin/* --depth=1
09:45:10 > git config remote.origin.url https://github.com/locusrobotics/robot_localization.git # timeout=10
09:45:10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
09:45:10 > git config remote.origin.url https://github.com/locusrobotics/robot_localization.git # timeout=10
09:45:10 Fetching upstream changes from https://github.com/locusrobotics/robot_localization.git
09:45:10 > git -c core.askpass=true fetch --tags --progress https://github.com/locusrobotics/robot_localization.git +refs/pull/*:refs/remotes/origin/pr/* --depth=1
09:45:12 > git rev-parse refs/remotes/origin/pr/17/merge^{commit} # timeout=10
09:45:12 > git rev-parse refs/remotes/origin/origin/pr/17/merge^{commit} # timeout=10
09:45:12 Merging Revision b6c7701d4057194a48d6f69f153e81de3178fb3e (refs/remotes/origin/pr/17/merge) to origin/indigo-devel, UserMergeOptions{mergeRemote='origin', mergeTarget='indigo-devel', mergeStrategy='default', fastForwardMode='--ff'}
09:45:12 > git rev-parse origin/indigo-devel^{commit} # timeout=10
09:45:12 > git config core.sparsecheckout # timeout=10
09:45:12 > git checkout -f origin/indigo-devel
09:45:13 > git merge --ff b6c7701d4057194a48d6f69f153e81de3178fb3e # timeout=10 ### THIS STEP FAILS! ###
09:45:13 > git config core.sparsecheckout # timeout=10
09:45:13 > git checkout -f b6c7701d4057194a48d6f69f153e81de3178fb3e
09:45:13 FATAL: null
09:45:13 java.lang.NullPointerException
09:45:13 at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:88)
09:45:13 at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1009)
09:45:13 at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1098)
09:45:13 at hudson.scm.SCM.checkout(SCM.java:485)
09:45:13 at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
09:45:13 at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
09:45:13 at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
09:45:13 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
09:45:13 at hudson.model.Run.execute(Run.java:1741)
09:45:13 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
09:45:13 at hudson.model.ResourceController.execute(ResourceController.java:98)
09:45:13 at hudson.model.Executor.run(Executor.java:410)
09:45:13 [WARNINGS] Skipping publisher since build result is FAILURE
The reason it fails is because the merge creates an add/add conflict, even though no conflict exists. Distilling the steps above, you can test the results with these commands:
git init robot_localization
cd robot_localization
git config remote.origin.url https://github.com/locusrobotics/robot_localization.git
git -c core.askpass=true fetch --tags --progress https://github.com/locusrobotics/robot_localization.git +refs/heads/*:refs/remotes/origin/* --depth=1
git -c core.askpass=true fetch --tags --progress https://github.com/locusrobotics/robot_localization.git +refs/pull/*:refs/remotes/origin/pr/* --depth=1
git rev-parse refs/remotes/origin/pr/17/merge^{commit}
git rev-parse refs/remotes/origin/origin/pr/17/merge^{commit}
git rev-parse origin/indigo-devel^{commit}
git config core.sparsecheckout
git checkout -f origin/indigo-devel
git merge --ff `git rev-parse refs/remotes/origin/pr/17/merge^{commit}`
To figure out what was going on, I went and looked at the output of some PR jobs on the ROS build server. Here’s the relevant output for gazebo_ros_pkgs
:
03:07:09 GitHub pull request #480 of commit 4e796b7857d9f4e3af025c2db2f9ec6864de8db3, no merge conflicts.
03:07:10 Setting status of 4e796b7857d9f4e3af025c2db2f9ec6864de8db3 to PENDING with url http://build.ros.org/job/Ipr__gazebo_ros_pkgs__ubuntu_trusty_amd64/35/ and message: 'Build started sha1 is merged.'
03:07:10 Using context: Ipr__gazebo_ros_pkgs__ubuntu_trusty_amd64
03:07:10 Building remotely on ip-172-31-6-90.us-west-1.compute.internal (swarm buildslave) in workspace /home/jenkins-slave/workspace/Ipr__gazebo_ros_pkgs__ubuntu_trusty_amd64
03:07:10 Cloning the remote Git repository
03:07:10 Using shallow clone
03:07:10 Cloning repository https://github.com/ros-simulation/gazebo_ros_pkgs.git
03:07:10 > git init /home/jenkins-slave/workspace/Ipr__gazebo_ros_pkgs__ubuntu_trusty_amd64/catkin_workspace/src/gazebo_ros_pkgs # timeout=10
03:07:10 Fetching upstream changes from https://github.com/ros-simulation/gazebo_ros_pkgs.git
03:07:10 > git --version # timeout=10
03:07:10 > git -c core.askpass=true fetch --tags --progress https://github.com/ros-simulation/gazebo_ros_pkgs.git +refs/heads/*:refs/remotes/origin/* --depth=1
03:07:12 > git config remote.origin.url https://github.com/ros-simulation/gazebo_ros_pkgs.git # timeout=10
03:07:12 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
03:07:12 > git config remote.origin.url https://github.com/ros-simulation/gazebo_ros_pkgs.git # timeout=10
03:07:12 Fetching upstream changes from https://github.com/ros-simulation/gazebo_ros_pkgs.git
03:07:12 > git -c core.askpass=true fetch --tags --progress https://github.com/ros-simulation/gazebo_ros_pkgs.git +refs/pull/*:refs/remotes/origin/pr/*
03:07:14 > git rev-parse refs/remotes/origin/pr/480/merge^{commit} # timeout=10
03:07:14 > git rev-parse refs/remotes/origin/origin/pr/480/merge^{commit} # timeout=10
03:07:14 Merging Revision d9136870d0ce8dc1b26556b8db9f15089630dbdd (refs/remotes/origin/pr/480/merge) to origin/indigo-devel, UserMergeOptions{mergeRemote='origin', mergeTarget='indigo-devel', mergeStrategy='default', fastForwardMode='--ff'}
03:07:14 > git rev-parse origin/indigo-devel^{commit} # timeout=10
03:07:14 > git config core.sparsecheckout # timeout=10
03:07:14 > git checkout -f origin/indigo-devel
03:07:14 > git merge --ff d9136870d0ce8dc1b26556b8db9f15089630dbdd # timeout=10
03:07:15 > git rev-parse HEAD^{commit} # timeout=10
03:07:15 Seen branch in repository origin/camera_info_dynamic_update
03:07:15 Seen branch in repository origin/gazebo7_warnings
...
The only difference between the two is this line:
09:30:45 > git -c core.askpass=true fetch --tags --progress https://github.com/locusrobotics/robot_localization.git +refs/pull/*:refs/remotes/origin/pr/* --depth=1
03:07:12 > git -c core.askpass=true fetch --tags --progress https://github.com/ros-simulation/gazebo_ros_pkgs.git +refs/pull/*:refs/remotes/origin/pr/*
While both have --depth=1
for the initial fetch (refs/heads
), but only I have that flag set for fetching the PRs.
So, armed with this information, I tested it:
git init robot_localization
cd robot_localization
git config remote.origin.url https://github.com/locusrobotics/robot_localization.git
git -c core.askpass=true fetch --tags --progress https://github.com/locusrobotics/robot_localization.git +refs/heads/*:refs/remotes/origin/* --depth=1
git -c core.askpass=true fetch --tags --progress https://github.com/locusrobotics/robot_localization.git +refs/pull/*:refs/remotes/origin/pr/*
git rev-parse refs/remotes/origin/pr/17/merge^{commit}
git rev-parse refs/remotes/origin/origin/pr/17/merge^{commit}
git rev-parse origin/indigo-devel^{commit}
git config core.sparsecheckout
git checkout -f origin/indigo-devel
git merge --ff `git rev-parse refs/remotes/origin/pr/17/merge^{commit}`
Sure enough, this works just fine.
So the question is why the PR job is using the --depth
switch at all. Looking at the job config, I see this:
It’s not clear if this is the source of the issue I’m seeing. The relevant build templates are here:
https://github.com/ros-infrastructure/ros_buildfarm/blob/master/ros_buildfarm/templates/devel/devel_job.xml.em#L60
https://github.com/ros-infrastructure/ros_buildfarm/blob/master/ros_buildfarm/templates/snippet/scm_git.xml.em
So my question is this: why am I seeing that flag? Is Jenkins parsing the configuration differently?