1

I'm trying to push all branches in a certain subdirectory to another subdirectory in another remote using a Jenkins job on a Windows server with this command:

git push bitbucket '+refs/remotes/origin/featureReady/*:refs/heads/company/featureReady/*'

This works with GIT bash:

$ git push bitbucket '+refs/remotes/origin/featureReady/*:refs/heads/company/featureReady/*'
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 663 bytes | 0 bytes/s, done.
Total 7 (delta 6), reused 0 (delta 0)
remote:
remote: Create pull request for company/featureReady/M5-UC-XXX_TestSyncProcess:
remote:   http://xxx/projects/project_name/repos/myrepo/compare/commits?sourceBranch=refs/heads/company/featureReady/M5-UC-XXX_TestSyncProcess
remote:
To ssh://xxx/project/project.git
 * [new branch]      origin/featureReady/M5-UC-XXX_TestSyncProcess -> company/featureReady/M5-UC-XXX_TestSyncProcess

But when Jenkins runs the same job, the new branch is not being detected:

C:\CI-Tools\Jenkins\workspace\myjob>git push bitbucket '+refs/remotes/origin/featureReady/*:refs/heads/company/featureReady/*' --dry-run --verbose 
Pushing to ssh://xxx/project/project.git
Everything up-to-date

I've tried setting the shell executable to %PROGRAMFILES%\Git\bin\sh.exe (specifying the absolute path) as described here, but the effect is the same.

Any idea what makes these behave differently and how to fix the jenkins job?

[edit] git status result:

$ git status
HEAD detached at 253c965
nothing to commit, working tree clean

[edit2] To test I always delete the branch created in the BitBucket server to have the same initial state. All the commands (Jenkins, GIT Bash and windows command line) are being ran in the same folder, which is the Jenkins checkout folder.

[edit3] When running the command with the Windows command line the result is also Everything up-to-date

Philippe
  • 1,949
  • 4
  • 31
  • 57
  • Maybe on the server everything *is* up to date? Can you run rev-parse on the branch heads and compare the hashes? – knittl Aug 12 '17 at 10:44
  • Unfortunately it's not. The branch doesn't show up in BitBucket after having ran the Jenkins job. If I run the command in git bash it's there. – Philippe Aug 12 '17 at 10:46
  • And the branch exists in `refs/remotes/origin/featureReady/` on your jenkins? (`git branch -a`) – knittl Aug 12 '17 at 10:52
  • Can you check what's the output of `git status` when you run with Jenkins? – thameera Aug 12 '17 at 10:53
  • I run git bash in the jenkins job directory, to be sure to have the same outcome. When it successfully commits the branch with git bash, I delete de branch in BitBucket. I'll update my answer with the `git status` result. – Philippe Aug 12 '17 at 10:56
  • I've finally figured out how to specify the ssh key when running the command through the windows command line. The result is also 'Everything up-to-date'. I don't get it!? – Philippe Aug 12 '17 at 11:51
  • I've finally configured the job to run with a windows task instead of Jenkins, this works fine. The ugly part is now that some jobs are windows tasks, other Jenkins ones. But at least the system is running. – Philippe Aug 14 '17 at 02:17

0 Answers0