pp2-demo-test-script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
node {
// try {
stage('Build'){
echo 'going to git clone......'
git url: 'https://gitee.com/roclli/5-build-tests.git'
echo "going to build.........."
sh "mvn -B -Dmaven.test.failure.ignore verify || true"
echo "going to archiveArtifacts jar.........."
archiveArtifacts artifacts: '**/target/**.jar', fingerprint: true
}

stage('Test'){
// sh 'mvn clean install || true'
// sh "mvn -B -Dmaven.test.failure.ignore verify"
echo "junit testreport.........."
junit '**/target/surefire-reports/TEST-**.xml'
}
// } catch(e) {
// currentBuild.result = "FAILURE"
// throw e
// }

stage('Deploy'){
echo "---env.BUILD_NUMBER is:${env.BUILD_NUMBER}---"
echo "---currentBuild.result is:${currentBuild.result}---"
echo "---env.BUILD_ID is:${env.BUILD_ID}---"
echo "---env.JOB_NAME is:${env.JOB_NAME}---"
echo "---env.JENKINS_URL is:${env.JENKINS_URL}---"
// echo "---"${BUILD_NUMBER}"---"
// echo "---1:"currentBuild.result"----2:${currentBuild.result}---"
// //SUCCESS, UNSTABLE, or FAILURE (may be null for an ongoing build)
if(currentBuild.result == null || currentBuild.result == 'SUCCESS') {
echo "---currentBuild.result is:${currentBuild.result}------"
}
else {
echo "---currentBuild.result is:${currentBuild.result},so, will make publish"
}
}

}