Jenkins文件以签出不同的回购并更新文件
我有2个repo A和B。在构建A结束时,我想用构建编号A更新repo B中的属性文件Jenkins文件以签出不同的回购并更新文件,jenkins,jenkins-pipeline,Jenkins,Jenkins Pipeline,我有2个repo A和B。在构建A结束时,我想用构建编号A更新repo B中的属性文件 我如何在回购A的Jenkin文件中为该阶段(最后一个阶段)签出回购B的主分支 结帐后,我可以按照以下步骤操作吗 下面提到的更新文件或有没有更好的方法 实现它 回购A的詹金斯文件: stage('Update properties file in repo B') { steps { script {
stage('Update properties file in repo B') {
steps {
script {
// how do I checkout master branch ofrepo B here?
sh "git config --global user.email jenkins@abc.com"
sh "git config --global user.name Jenkins"
sh(script: 'echo "repoA_VERSION=$BUILD_NUMBER" > version.properties', returnStdout: true).trim()
git add .
git commit -m "Updated version.properties file with ${env.BUILD_NUMBER}"
}
}
}
您只需调用git步骤: 例如 如果您不知道凭据的标识符,可以转到:
your_jenkins_server:8080/job/job_name/pipeline-syntax/
如果job_name是服务器中的任何作业,并且您将访问管道语法,那么您可以配置git checkout并生成命令:
2号,,
代码必须在sh命令中:
sh """git add .
git commit -m "Updated version.properties file with ${env.BUILD_NUMBER}"
git push
"""
最后一个建议是,避免使用git add.,并单独或使用通配符添加文件。我是否应该将分支称为
master
或refs/heads/master
分支必须指定为:mastergot errorgit:“branch:master”不是git命令。请参阅“git--help”。
当我尝试时,git branch:“您的分支”,credentialsId:“您的凭证”,url:“您的凭证”git branch:“您的分支”,credentialsId:“您的凭证”,url:“您的凭证”必须出现在您键入的位置//如何在此处签出PO B的主分支?
是,我只是在那里添加了它,得到了错误:git:'branch:master'不是git命令。请参阅“git--help”
sh """git add .
git commit -m "Updated version.properties file with ${env.BUILD_NUMBER}"
git push
"""