Multiple SCM will not support the functionality fully.
Writing the stages in the Pipeline would do this. In the following Snippet, assuming there is a file called dummy1.cfg in the First Repo A. We clone Repo A, post which we clone the second Repo B, move the dummy1.config file to the folder where we clone Repo B and push changes from there to Repo B.
pipeline {
agent any
stages {
stage('Cloning Repo A') {
steps {
git branch: 'master',
credentialsId: 'Innersource_Cred',
url: 'https://innersource.com/scm/~i/repo_a.git'
}
}
stage('Clone Repo B') {
steps {
dir("/root/repo_b") {
git branch: 'master',
credentialsId: 'Innersource_Cred',
url: 'https://innersource.com/scm/~i/repo_b.git'
}
}
}
stage('Move File') {
steps {
sh 'cp /var/jenkins_home/workspace/${JOB_NAME}/dummy1.cfg /root/repo_b'
}
}
stage('Push File') {
steps {
dir("/root/repo_b") {
withCredentials([usernamePassword(credentialsId: 'Innersource_Cred',
usernameVariable: 'Username',
passwordVariable: 'Password')]) {
sh '''
git pull https://${Username}:${Password}@innersource.com/scm/~i/repo_b.git
git add .
git commit -m "push to git"
git push https://${Username}:${Password}@innersource.com/scm/~i/repo_b.git
'''
}
}
}
}
}
}
If Git Credentials are using key authentication, use Jenkins Plugin withCredentials([sshUserPrivateKey(credentialsId: 'Innersource_Credentials', keyFileVariable: 'SSH_KEY')]) {
'''
Type commands here
'''
}