forked from HariSekhon/Nagios-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
134 lines (118 loc) · 3.77 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env groovy
// vim:ts=4:sts=4:sw=4:et:filetype=groovy:syntax=groovy
//
// Author: Hari Sekhon
// Date: 2017-06-28 12:39:02 +0200 (Wed, 28 Jun 2017)
//
// https://github.com/harisekhon/nagios-plugins
//
// License: see accompanying Hari Sekhon LICENSE file
//
// If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
//
// https://www.linkedin.com/in/harisekhon
//
// ========================================================================== //
// J e n k i n s P i p e l i n e
// ========================================================================== //
// https://jenkins.io/doc/book/pipeline/syntax/
pipeline {
// run pipeline any agent
agent any
// can't do this when running jenkins in docker itself, gets '.../script.sh: docker: not found'
// agent {
// docker {
// image 'ubuntu:18.04'
// args '-v $HOME/.m2:/root/.m2 -v $HOME/.cache/pip:/root/.cache/pip -v $HOME/.cpanm:/root/.cpanm -v $HOME/.sbt:/root/.sbt -v $HOME/.ivy2:/root/.ivy2 -v $HOME/.gradle:/root/.gradle'
// }
// }
// need to specify at least one env var if enabling
//environment {
// DEBUG = '1'
//}
options {
// put timestamps in console logs
timestamps()
// timeout entire pipeline after 4 hours
timeout(time: 4, unit: 'HOURS')
//retry entire pipeline 3 times
//retry(3)
}
triggers {
cron('H 10 * * 1-5')
pollSCM('H/2 * * * *')
}
stages {
stage ('Checkout') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '', url: 'https://github.com/harisekhon/nagios-plugins']]])
}
}
stage('Build') {
steps {
echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"
echo 'Building...'
timeout(time: 10, unit: 'MINUTES') {
retry(3) {
// sh 'apt update -q'
// sh 'apt install -qy make'
// sh 'make init'
sh """
apt update -q &&
apt install -qy make &&
make init
"""
}
}
timeout(time: 180, unit: 'MINUTES') {
sh 'make ci'
}
}
}
stage('Test') {
options {
retry(2)
}
steps {
echo 'Testing...'
timeout(time: 120, unit: 'MINUTES') {
sh 'make test'
}
}
}
// stage('Human gate') {
// steps {
// input "Proceed to deployment?"
// }
// }
//
// stage('Deployment') {
// steps {
// echo 'Deploying...'
// echo 'Nothing to deploy'
// }
// }
}
post {
always {
echo 'Always'
//deleteDir() // clean up workspace
// collect JUnit reports for Jenkins UI
//junit 'build/reports/**/*.xml'
// collect artifacts to Jenkins for analysis
//archiveArtifacts artifacts: 'build/libs/**/*.jar', fingerprint: true
}
success {
echo 'SUCCESS!'
}
failure {
echo 'FAILURE!'
}
unstable {
echo 'UNSTABLE!'
}
changed {
echo 'Pipeline state change! (success vs failure)'
}
}
}