Jenkins使用Multiple SCMs插件或者Pipline Scripts实现多仓库的发布
实现多仓库的发布(前后端分离的两个工程合并)
方式一:使用Multiple SCMs插件实现
因为git不允许克隆到一个非空目录,所以中转一下资源。
方式二:使用Pipline Scripts实现(可用pipeline-syntax生成)
node {
stage("Checkout") {
checkout([$class: "GitSCM", branches: [[name: "*/develop"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: "git@192.168.1.248:mall/www-xxx-cms.git"]]])
checkout([$class: "GitSCM", branches: [[name: "*/master"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: "RelativeTargetDirectory", relativeTargetDir: "www_cms_resources"]], submoduleCfg: [], userRemoteConfigs: [[url: "git@192.168.1.248:2019_lx_group/www_cms_resouces.git"]]])
sh(script: "mv www_cms_resources/* www-cms-web/src/main/resources/")
}
}
参考资料
- https://www.w3cschool.cn/jenkins/jenkins-173a28n4.html
- https://www.jenkins.io/doc/book/blueocean/getting-started/
- https://github.com/jenkinsci/jenkins/
- https://www.jenkins.io/zh/doc/tutorials/build-a-multibranch-pipeline-project/
- https://www.jenkins.io/doc/pipeline/steps/workflow-scm-step/
- 解决 fatal: destination path “./somefolder” already exists and is not an empty directory.