forked from san5167/EventRetriever
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
74 lines (67 loc) · 2.28 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
pipeline {
agent {
kubernetes {
//cloud 'kubernetes'
defaultContainer 'openjdk'
yaml '''
kind: Pod
spec:
containers:
- name: openjdk
image: openjdk:latest
imagePullPolicy: Always
command:
- sleep
args:
- 99d
'''
}
}
stages {
stage('Hello') {
steps {
echo 'Hello World'
}
}
// 这里的hello2 是我加的,就是说明,这是stages下的第二个任务 ,就是在pipeline中加单行注释 用 // 就行
stage('Hello2') {
steps {
sh '''echo \'Hello World,i 应该是 可以了 -2 !!!\'
ls -a /home/jenkins/agent/workspace'''
}
}
stage('SCM') {
steps {
git 'https://github.com/san5167/MyTestRepository.git'
}
}
stage('SonarQube analysis') {
steps {
script {
def scannerHome = tool 'sonar-devops';
withSonarQubeEnv('sonarqube-scanner') { // If you have configured more than one global server connection, you can specify its name
sh "pwd";
sh "ls";
sh "ls ${scannerHome}";
sh "cat ${scannerHome}/bin/sonar-scanner";
sh "${scannerHome}/bin/sonar-scanner -X -Dsonar.projectKey=develop";
}
}
}
}
//前
stage('sonar load result'){
steps{
script{
timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout
def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}
//后
}
}