如何使用jenkins部署jar包
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何使用jenkins部署jar包相关的知识,希望对你有一定的参考价值。
参考技术A #!/bin/bashcd /deploy_cmp_script
echo "Execute shell Start"
sh stop.sh
sh replace.sh
echo "Execute shell Finish"
jenkins+saltstack+pipeline 部署springcloud 多模块jar包
在jenkins上安装salt-master,
pipeline{
agent{
node{
label ‘master‘
customWorkspace ‘/srv/salt/xxx/result‘
}
}
parameters {
choice(name: ‘app_name‘, choices: [‘xxx-client‘, ‘xx-server‘, ‘xx‘], description: ‘app_name‘)
choice(name: ‘server_name‘, choices: [‘10.83.64.143‘], description: ‘server_name‘)
string(name: ‘version‘,description: ‘branch‘)
}
environment {
APP_NAME = "${params.app_name}"
}
tools {
maven ‘M3‘
jdk ‘jdk1.8.0_92‘
}
stages{
stage(‘get code‘){
steps{
checkout([$class: ‘SubversionSCM‘, additionalCredentials: [], excludedCommitMessages: ‘‘, excludedRegions: ‘‘, excludedRevprop: ‘‘, excludedUsers: ‘‘, filterChangelog: false, ignoreDirPropChanges: false, includedRegions: ‘‘, locations: [[cancelProcessOnExternalsFail: true, credentialsId: ‘svnchenbin‘, depthOption: ‘infinity‘, ignoreExternalsOption: true, local: ‘.‘, remote: "https://10.83.32.2/svn/xx/xxx/branches/${params.version}/xx"]], quietOperation: true, workspaceUpdater: [$class: ‘UpdateUpdater‘]])
}
}
stage(‘build‘){
parallel {
stage(‘build-xx‘){
when { environment name: ‘APP_NAME‘, value: ‘xxxx‘ }
steps{
sh ‘mvn clean install -Dmaven.test.skip=true -f xxx/pom.xml‘
}
}
stage(‘build-xx-x-server‘){
when {
anyOf{
environment name: ‘APP_NAME‘, value: ‘xx-client‘
environment name: ‘APP_NAME‘, value: ‘xx-server‘
}
}
steps{
sh ‘mvn clean install -Dmaven.test.skip=true -f pom.xml‘
}
}
}
}
stage(‘deploy‘){
steps{
sh "/usr/local/python3/bin/salt $server_name state.sls xxx/$app_name"
}
}
}
post {
always {
echo "Send notifications for result: ${currentBuild.currentResult}}"
sh ‘/usr/local/python3/bin/salt $server_name cmd.run "ps -ef|grep $app_name|grep -v grep"‘
}
}
}
以上是关于如何使用jenkins部署jar包的主要内容,如果未能解决你的问题,请参考以下文章
如何将springboot项目打包成jar包并部署到服务器上