I am currently trying to publish some built assets as npm package, to be able to pull it onto different environments like staging or production.
My Pipeline
- a docker agent (own image: alpine + git + ssh)
- 3 stages
- build (npm install/build, private registry)
- test
- publish
- npm version (does change package.json and package-lock.json)
- npm publish (package is saved in private registry)
- git add ... git commit ... (I thought those are done by npm version but...no?!)
- git push <= here is the problem
The error:
git push HEAD:refs/remotes/origin/master
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push HEAD:refs/remotes/origin/master HEAD:<name-of-remote-branch>
I already tried some different git push calls like:
git push -u ${env.GIT_BRANCH} HEAD:${env.GIT_BRANCH}
git push -u origin HEAD:${env.GIT_COMMIT}
git push HEAD:refs/remotes/${env.GIT_BRANCH}
With
GIT_BRANCH=origin/master
GIT_COMMIT=0e0037b8ec27345f83ff4e08f1cf6133d3889dda
git show-ref
0e0037b8ec27345f83ff4e08f1cf6133d3889dda refs/remotes/origin/master
Update:
After changing into a branch with git checkout -b temp_${env.BUILD_NUMBER}
and
git push --repo ${GIT_URL} --set-upstream ${GIT_URL} ${env.GIT_BRANCH}
the error changes to
! [remote rejected] origin/master -> origin/master (deny updating a hidden ref)
error: failed to push some refs to 'git@...myrepo.git'