diff --git a/Jenkinsfile b/Jenkinsfile index 5deffd5..0a8ef7c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,20 +12,20 @@ pipeline { checkout scmGit(branches: [[name: '${tag}']], extensions: [], userRemoteConfigs: [[url: 'https://git.mashibing.com/msb_134187/ljj_spring_test.git']]) } } - stage('maven打包') { // 阶段2:使用maven进行应用打包 - steps { - try { - timeout(time: 5, unit: 'SECONDS') { - echo '开始执行 Maven 打包...' - sh 'echo 123' - echo 'Maven 打包完成.' - } - } catch (err) { - echo "打包出错:${err.getMessage()}" - } - - } - } + stage('Execute Shell Command') { + steps { + script { + try { + // 尝试执行shell命令 + sh label: '', script: 'echo 123' + } catch (err) { + // 如果执行时发生异常,则捕获并打印错误信息 + echo "Shell command execution failed: ${err.getMessage()}" + // 这里还可以添加其他处理错误的逻辑,比如发送通知、清理资源等 + } + } + } + } stage('sonar质量检测') { // 阶段3:使用Sonar进行代码质量检测 steps { echo 'sonar质量检测--成功' // 打印信息表示质量检测阶段成功完成