-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
101 lines (94 loc) · 2.79 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!groovy
def show_build_change_info(build) {
def changeLogSets = build.changeSets
def resultlist = []
if (changeLogSets.size() == 0) {
resultlist.add(" Empty changeSets?!")
}
for (int i = 0; i < changeLogSets.size(); i++) {
resultlist.add(" Changeset ${i}:")
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
def entry = entries[j]
resultlist.add(" Commit: ${entry.commitId}")
resultlist.add(" by: ${entry.author}")
resultlist.add(" on: ${new Date(entry.timestamp)}")
resultlist.add(" Text:")
resultlist.add(" | ${entry.msg}")
resultlist.add(" Files:")
def files = new ArrayList(entry.affectedFiles)
for (int k = 0; k < files.size(); k++) {
def file = files[k]
resultlist.add(" - ${file.editType.name} ${file.path}")
}
}
}
return resultlist.join('\n')
}
// currentBuild.rawBuild.getParent().setQuietPeriod(300)
String cron_string = ""
Integer quietperiod = 0;
if (BRANCH_NAME == "master") {
cron_string = "H H 6 * *";
}
if (env.CHANGE_ID == null) {
quietperiod = 35;
}
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '12'))
quietPeriod(quietperiod)
}
triggers {
cron("H H * * *")
}
agent none
stages {
stage('Check Whitelist') {
input {
message "Should we continue?"
ok "Yes, we should."
submitter "alice,bob"
submitterParameter "whopressed"
}
steps {
echo "who pressed: ${whopressed}"
}
}
stage('First stage / checkout') {
steps {
node("") {
checkout scm
/* deleteDir() */
}
echo "Start"
echo "BRANCH_NAME: ${BRANCH_NAME}"
echo "env.BRANCH_NAME: ${env.BRANCH_NAME}"
echo "env.CHANGE_ID: ${env.CHANGE_ID}"
echo "env.CHANGE_TARGET: ${env.CHANGE_TARGET}"
echo "getBuildCauses: ${currentBuild.getBuildCauses()}"
echo "cron: ${cron_string}"
echo "quietperiod: ${quietperiod}"
script {
def change_info = ""
change_info = show_build_change_info(currentBuild)
println "- ${currentBuild.displayName}\n${change_info}"
def parent = currentBuild.getPreviousBuild()
while (parent != null) {
change_info = show_build_change_info(parent)
println "- ${parent.displayName}, ${parent.result}:\n${change_info}"
parent = parent.getPreviousBuild()
}
}
}
}
stage('timer stage') {
when {
triggeredBy 'TimerTrigger'
}
steps {
echo 'By timer'
}
}
}
}