从 Gerrit 到 Bitbucket 的远程分支
Remote branches from Gerrit to Bitbucket
最近我们从使用 gerrit 转移到了 Bitbucket。 Gerrit 中很少有远程分支需要同步到 Bitbucket。由于分支数量很多,因此需要自动化。任何指针都会有所帮助
示例 jenkinsfile 以将远程分支从 gerrit 推送到 Bitbucket -
// ssh credentials
def credentials_id = 'XXXXXXXXXXXXXXX-UUUUUU-III'
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '600'))
disableConcurrentBuilds()
}
agent { node { label 'Master' } }
stages {
stage('try') {
steps {
checkout(
[
$class: 'GitSCM',
branches: [
[
name: '${gerrit-branch-name}'
]
],
doGenerateSubmoduleConfigurations: false,
extensions: [
[
$class: 'CheckoutOption',
timeout: 20
],
[ $class: 'LocalBranch',
localBranch: '${local-branch-name-bitbucket}'
]
],
gitTool: 'Default',
submoduleCfg: [],
userRemoteConfigs: [
[
credentialsId: credentials_id,
name: 'gerrit',
url: '${gerrit-URL}'
],
[
credentialsId: credentials_id,
name: 'bitbucket',
url: '${bitbucket-URL}'
]
]
]
)
}
}
stage('Push updates of branch to Bitbucket') {
steps {
bat 'git push --tags bitbucket ${gerrit-branch-name}:refs/heads/${local-branch-name-bitbucket}`enter code here`'
}
}
}
}
最近我们从使用 gerrit 转移到了 Bitbucket。 Gerrit 中很少有远程分支需要同步到 Bitbucket。由于分支数量很多,因此需要自动化。任何指针都会有所帮助
示例 jenkinsfile 以将远程分支从 gerrit 推送到 Bitbucket -
// ssh credentials
def credentials_id = 'XXXXXXXXXXXXXXX-UUUUUU-III'
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '600'))
disableConcurrentBuilds()
}
agent { node { label 'Master' } }
stages {
stage('try') {
steps {
checkout(
[
$class: 'GitSCM',
branches: [
[
name: '${gerrit-branch-name}'
]
],
doGenerateSubmoduleConfigurations: false,
extensions: [
[
$class: 'CheckoutOption',
timeout: 20
],
[ $class: 'LocalBranch',
localBranch: '${local-branch-name-bitbucket}'
]
],
gitTool: 'Default',
submoduleCfg: [],
userRemoteConfigs: [
[
credentialsId: credentials_id,
name: 'gerrit',
url: '${gerrit-URL}'
],
[
credentialsId: credentials_id,
name: 'bitbucket',
url: '${bitbucket-URL}'
]
]
]
)
}
}
stage('Push updates of branch to Bitbucket') {
steps {
bat 'git push --tags bitbucket ${gerrit-branch-name}:refs/heads/${local-branch-name-bitbucket}`enter code here`'
}
}
}
}