I've configured a Jenkins job with multiple repositories in the "Source Code Management" section, with each one getting a "custom" origin name. The use case is that I need to pull a checksum value from the first repo, and then use that to update a file in the second repo and push that change up to the remote repo. Here's what the Jenkins job output looks like:
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from 2 remote Git repositories
> git config remote.second-origin.url [email protected]:user/repo-2.git # timeout=10
Fetching upstream changes from [email protected]:user/repo-2.git
> git --version # timeout=10
using GIT_SSH to set credentials
> git fetch --tags --progress [email protected]:user/repo-2.git +refs/heads/*:refs/remotes/second-origin/*
> git config remote.first-origin.url [email protected]:user/repo-1.git # timeout=10
Fetching upstream changes from [email protected]:user/repo-1.git
using GIT_SSH to set credentials
> git fetch --tags --progress [email protected]:user/repo-1.git +refs/heads/*:refs/remotes/first-origin/*
Seen branch in repository second-origin/development
Seen branch in repository second-origin/master
Seen branch in repository first-origin/master
Seen branch in repository first-origin/test
Seen 4 remote branches
Checking out Revision 15j5123hjhjkl5123jk512hjkl5hjk5jhkl (first-origin/test)
> git config core.sparsecheckout # timeout=10
> git checkout -f 15j5123hjhjkl5123jk512hjkl5hjk5jhkl
> git rev-list 15j5123hjhjkl5123jk512hjkl5hjk5jhkl # timeout=10
[Jenkins Job] $ /bin/sh -xe /tmp/hudson2801366816478454446.sh
+ git config --global user.name jenkins-deploy
+ git config --global user.email [email protected]
+ git checkout first-origin/master
Previous HEAD position was 15j51... Some stuff
HEAD is now at f2f34af23.. Merging master
++ git rev-parse HEAD
+ echo f2f34af23a2g3hLKJHGQLK2HJ > current.rev
+ git branch -d development
warning: deleting branch 'development' that has been merged to
'refs/remotes/second-origin/development', but it is not yet merged to HEAD.
Deleted branch development (was 15bfafb).
+ git checkout -b development second-origin/development
Previous HEAD position was f8c45cf... Merging master
Switched to a new branch 'development'
Branch development set up to track remote branch development from second-origin.
+ cat current.rev >> file-changed.txt
+ git add file-changed.txt
+ git commit -m 'updating file-changed.txt'
[development 4fd83aa] updating file-changed.txt
1 files changed, 1 insertions(+), 1 deletions(-)
+ git push second-origin development
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
Build step 'Execute shell' marked build as failure
Notifying upstream projects of job completion
Finished: FAILURE
I've also tried every flavor of the git push command I can think of, but nothing works:
git push -u second-origin development
git push
git push development
git push second-origin/development
git push second-origin:development
git push second-origin
git push remotes/second-origin
git push remotes/second-origin/development
git push second-origin user/repo-2/development
git push second-origin user/repo-2:development
git push second-origin user/repo-2 development
I have a feeling this is related to Jenkins inserting the git config core.sparsecheckout
, but can't find anything useful on the subject.
I fixed this by updating the shell command:
git checkout second-origin/development
second-origin
.