I want to syncronize two repositories each time a build is been made, I have seen this script but I don't know how to set the remote branch with credentials too.
# clone the reposotory
git clone --bare $ORIGIN_URL
# add a remote repository
cd $REPO_NAME
git remote add --mirror=fetch repo1 $REPO1_URL
# update the local copy from the first repository
git fetch origin --tags
# update the local copy with the second repository
git fetch repo1 --tags
# sync back the 2 repositories
git push origin --all
git push origin --tags
git push repo1 --all
git push repo1 --tags
Pipeline:
node('centos-small') {
sh 'git config --global user.email "jenkins@xxx.com"'
sh 'git config --global user.name "ci-bot"'
git credentialsId: 'JenkinsGit', url: 'git url'
}
I don't know how to set the credentials to push changes to remote repo. git push repo1 --all git push repo1 --tags