實現多倉庫的發佈(前後端分離的兩個工程合併)
方式一:使用Multiple SCMs插件實現
因爲git不允許克隆到一個非空目錄,所以中轉一下資源。
方式二:使用Pipline Scripts實現(可用pipeline-syntax生成)
node {
stage('Checkout') {
checkout([$class: 'GitSCM', branches: [[name: '*/develop']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: '[email protected]:mall/www-xxx-cms.git']]])
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'www_cms_resources']], submoduleCfg: [], userRemoteConfigs: [[url: '[email protected]: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.
補充
- 問題(mv命令的缺陷,當然可以先刪除再執行):
mv: 無法將"www_cms_resources/static" 移動至"www-cms-web/src/main/resources/static": 文件已存在
mv: 無法將"www_cms_resources/templates" 移動至"www-cms-web/src/main/resources/templates": 文件已存在
- 解決(這裏直接使用cp命令替代):
\cp -rf www_cms_resources/* www-cms-web/src/main/resources/
\cp -rf www_cms_resources/* www-cms-web/src/main/resources/