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

7
  • Maybe on the server everything is up to date? Can you run rev-parse on the branch heads and compare the hashes? Commented Aug 12, 2017 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. Commented Aug 12, 2017 at 10:46
  • And the branch exists in refs/remotes/origin/featureReady/ on your jenkins? (git branch -a) Commented Aug 12, 2017 at 10:52
  • Can you check what's the output of git status when you run with Jenkins? Commented Aug 12, 2017 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. Commented Aug 12, 2017 at 10:56

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.