Jenkins GIT submodule tagging not correct

693 views Asked by At

I am running a build job with a Project A and submodule project B. Both projects have a fork where we are tracking the tags.

So, the following projects are given:

Project A
- Fork Project A-fork 
Project B (submodule of A)
- Fork Project B-Fork

Goal: After build, I want to add a tag to A-fork as well as B-fork to know, which code commits are taken in both projects.

Problem: I was adding A (name "origin"), A-fork (forkA) and B-fork (forkB) to Jenkins GIT repositories. Advanced submodule behaviour is set to "Recursively update submodules" and "Update tracking submodules to tip of branch".

As a post-build step, I am pushing the tags via console:

git push forkA refs/tags/${RELEASE_TAG} 
git push forkB refs/tags/${RELEASE_TAG} 

So, now the real Problem: When performing like this, the tag which is pushed to forkB (my submodule) is referring to a commit in my parent repository A, but not on the latest code used as submodule in B.

How can I adopt this so that my tag is referring to latest commit in submodule B?

Thanks Christian

1

There are 1 answers

0
Christo On

Ok, I know fixed it "manually" as a execute shell step.

git push forkA refs/tags/${RELEASE_TAG} 

# Cleanup workspace, keeping git config
find . ! -path . | grep -v ".git" | xargs rm -rf
HASH=`git rev-parse refs/remotes/forkB/master^{commit}`
git checkout -f ${HASH}
git tag -a ${RELEASE_TAG}-forkB -m "ForkB Ref: ${RELEASE_TAG}"
git push forkB refs/tags/${RELEASE_TAG}-forkB

Not very nice, but working.