wangzilun
2022-03-08 f84e9b6dd5413f873e6b32b146af21ba0749135f
Jenkinsfile
@@ -29,6 +29,11 @@
                                    , userRemoteConfigs: [[credentialsId: "${GIT_CREDENTIALS_ID}", url: "${url}"]]
                                    ])
                     println "changeLogSets ${changeLogSets}"
                     GIT_COMMIT = changeLogSets['GIT_COMMIT']
                     GIT_PREVIOUS_COMMIT = changeLogSets['GIT_PREVIOUS_COMMIT']
                     env.GIT_COMMIT_AUTHOR = sh (script: 'git log -1 --oneline --pretty=%an ${GIT_COMMIT}', returnStdout: true).trim()
                     env.GIT_COMMIT_MSG = sh (script: 'git log --oneline --pretty=%s ${GIT_PREVIOUS_COMMIT}...${GIT_COMMIT}| sed = |sed "N;s/\\n/./"', returnStdout: true).trim()
                }
            }
        }
@@ -40,17 +45,6 @@
            //}
        //}
        stage('testFunction') {
            steps {
                sh '''
                    commit_name="\$(git show -s --pretty=%an)"
                    commit_message="\$(git show -s --pretty=%s)"
                    echo "\$commit_name"
                    echo "\$commit_message"
                    printenv
                '''
            }
        }
        //将项目打成war并归档,将配置文件目录存入stash
        stage('package') {
@@ -70,6 +64,7 @@
                    ##mkdir \$dir_name
                    ##cp *.war \$dir_name
                    ##zip -r "\$dir_name.zip" \$dir_name
                    exit 1
                '''
            }
        }
@@ -123,4 +118,32 @@
            }
        }
    }
    post {
        unsuccessful {
            script{
            env.BUILD_URL = "${BUILD_URL}"
                 sh '''
                    msg="当前构建失败<br>提交人:${GIT_COMMIT_AUTHOR}<br>提交信息:<br>${GIT_COMMIT_MSG}<br> 构建内网链接:${BUILD_URL}"
                    echo "$msg"
                    sendqq(){
                      rm -f tmp_in
                      mknod tmp_in p
                      exec 8<> tmp_in
                      telnet zllr.top 9588 <&8 &
                      sleep 5
                      echo "send -t qq -fn $1 $2 >> tmp_in"
                      echo "send -t qq -fn $1 $2" >> tmp_in
                      sleep 1
                      echo "exit" >> tmp_in
                    }
                    sendqq "964606955" "${msg}"
                 '''
            }
        }
    }
}