forked from openebs-archive/mayastor-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
88 lines (81 loc) · 2.55 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
#!/usr/bin/env groovy
def mainBranches() {
return BRANCH_NAME == "develop" || BRANCH_NAME.startsWith("release/");
}
// TODO: Use multiple choices
helm_test = true
run_tests = params.run_tests
// Will skip steps for cases when we don't want to build
if (currentBuild.getBuildCauses('jenkins.branch.BranchIndexingCause') && mainBranches()) {
print "INFO: Branch Indexing, skip tests and push the new images."
run_tests = false
}
// Only schedule regular builds on main branches, so we don't need to guard against it
String cron_schedule = mainBranches() ? "0 2 * * *" : ""
pipeline {
agent none
options {
timeout(time: 2, unit: 'HOURS')
}
parameters {
booleanParam(defaultValue: true, name: 'run_tests')
}
triggers {
cron(cron_schedule)
}
stages {
stage('init') {
agent { label 'nixos-mayastor' }
steps {
step([
$class: 'GitHubSetCommitStatusBuilder',
contextSource: [
$class: 'ManuallyEnteredCommitContextSource',
context: 'continuous-integration/jenkins/branch'
],
statusMessage: [ content: 'Pipeline started' ]
])
}
}
stage('chart publish test') {
when {
expression { helm_test == true }
}
agent { label 'nixos-mayastor' }
steps {
sh 'printenv'
sh 'nix-shell --pure --run "./scripts/helm/test-publish-chart-yaml.sh" ./shell.nix'
}
}
}
// The main motivation for post block is that if all stages were skipped
// (which happens when running cron job and branch != develop) then we don't
// want to set commit status in github (jenkins will implicitly set it to
// success).
post {
always {
node(null) {
script {
// If no tests were run then we should neither be updating commit
// status in github nor send any slack messages
if (currentBuild.result != null) {
step([
$class : 'GitHubCommitStatusSetter',
errorHandlers : [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
contextSource : [
$class : 'ManuallyEnteredCommitContextSource',
context: 'continuous-integration/jenkins/branch'
],
statusResultSource: [
$class : 'ConditionalStatusResultSource',
results: [
[$class: 'AnyBuildResult', message: 'Pipeline result', state: currentBuild.getResult()]
]
]
])
}
}
}
}
}
}