利用Jenkins的Pipeline配置發佈流水線git
新建一個名爲pipeline-loop的 pipeline項目,而後配置,關鍵配置以下:gitlab
生成pipeline能夠用的git鏈接(經過此連接,從私有gitlab拉取代碼)ui
Pipeline生成: https://jenkins.aniu.so/view/...url
生成的pipeline代碼以下,後面配置會用到:spa
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '500378f5-a6e4-4255-984e-61537fe0e455', url: 'git@gitlab.aniu.so:aniu-yunwei/game-of-life.git']]])
配置pipeline-loop項目code
pipeline { agent any stages { stage('Checkout') { steps { echo 'Checkout' checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '500378f5-a6e4-4255-984e-61537fe0e455', url: 'git@gitlab.aniu.so:aniu-yunwei/game-of-life.git']]]) } } stage('Build') { steps { echo 'Building' sh 'mvn clean install' # 能夠用本身的 mvn clean deploy + 參數替代 } } stage('Test') { steps { echo 'Testing' sh 'mvn clean verify sonar:sonar' # 此處可使用mvn test替代,筆者這步是檢測代碼的質量同步到本身的代碼質量檢測平臺。 } } stage('Deploy') { steps { echo 'Deploying' sh 'mvn clean deploy' # 此處調用腳本或者ansible、saltstak,部署到遠程 } } } }
配置完成保存,而後build此項目,查看結果以下:ip