Jenkins代码详见:
https://gitee.com/roclli/5-build-tests.git
Jenkinsfile内容为: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
41
42
43
44
45
46
47#!/usr/bing/env groovy
pipeline {
agent any //agent必需的,告诉Jenkins分配执行器和工作空间
stages { //stage必需的,
stage('Build') {
steps { //step必需的
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"
echo "going to archiveArtifacts jar.........."
archiveArtifacts artifacts: '**/target/**.jar', fingerprint: true
}
}
stage('Test'){
steps{
// sh '/mvn_home/bin/mvn clean install || true'
// sh "/mvn_home/bin/mvn -B -Dmaven.test.failure.ignore verify"
echo "junit testreport.........."
junit '**/target/surefire-reports/TEST-**.xml'
}
}
stage('Deploy'){
steps {
script{
echo "---${env.BUILD_NUMBER}---"
echo "---${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}---"
if(currentBuild.result == null || currentBuild.result == "SUCCESS") {
echo "---currentBuild.result is:${currentBuild.result}------"
}
else {
echo "---currentBuild.result is:${currentBuild.result},so, will make publish"
}
}
}
}
}
}