利用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