简介
使用jenkins部署时会读取项目中Jenkinsfile文件,文件配置不对会导致部署失败
文件内容
pipeline {agent anyparameters {string(name: 'project_name', defaultValue: 'xxx1', description: '项目jar名称')string(name: 'version', defaultValue: 'xxx2', description: '部署环境')string(name: 'user_name', defaultValue: 'xxx3', description: '操作系统登录名')}stages {stage('构建') {steps {sh """mvn clean install -U -Dmaven.test.skip=true -DprofileActive=${params.version}"""}}stage('发布') {steps {sh """/root/killJar.sh ${params.version}/${params.project_name}/boot/${params.project_name}.jarrm -rf /home/${params.user_name}/api/${params.project_name}-${params.version}-1.0.0.tar.gzrm -rf /home/${params.user_name}/api/${params.version}cp ./target/${params.project_name}-${params.version}-1.0.0.tar.gz /home/${params.user_name}/xxxcd /home/${params.user_name}/apimkdir ${params.version}chown ${params.user_name}:${params.user_name} ${params.project_name}-${params.version}-1.0.0.tar.gztar -zxvf ${params.project_name}-${params.version}-1.0.0.tar.gz -C ${params.version}cd ${params.version}pwdchown -R ${params.user_name}:${params.user_name} ${params.project_name}su - ${params.user_name} -c /home/xxx/xxx/${params.version}/${params.project_name}/bin/startup.sh"""}}}
}