I\'m trying to create a new project configuration for Jenkins build server. To simplify what I\'m trying to do, I will use only two components to describe the problem.
C
Using the Credentials Binding Plugin worked very well for me (also mentioned by @zeppelin)
Add Credentials
of the type: "Username with password". This should be the username and password for component B repository git server using HTTPS protocol (the SSH option is not good for this purpose) Git
section all required fields (Repositories, Branches, etc.).
Check out to a sub-directory
and write: component_a
Build when a change is pushed to GitHub
In the Build Environment section tick the Use secret text(s) or file(s)
Variable
some name: MY_CREDCredentials
choose the Specific credentials you created in step 1.
Now using the MY_CRED
in the Execute shell code you will have access to the component B repository:
DIR="component_b"
if [ "$(ls -A $DIR/.git)" ]; then
cd $DIR
git fetch
else
git clone https://$MY_CRED@github.com/proj/component_b.git $DIR
cd $DIR
fi
git show
git clone 'https://****@github.com/proj/component_b.git' component_b
Do all your parsing of config from component A to get the desired tag: TAG=$(cat ./component_a/config.cfg | grep ... | sed ...)
cd component_b; git checkout -f $TAG
-f
force tag.