Skip to content

Commit 6f83fce

Browse files
committedSep 27, 2017
Problem: Start with jenkins pipeline is hard
Solution: Add jenkins target to create nice working pipeline file.
1 parent ec15a32 commit 6f83fce

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed
 

‎AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ Kouhei Sutou
2121
Andreas Potschka
2222
Arnaud Quette
2323
James Gatannah
24+
Tomas Halman

‎README.md

+10
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ zproject's `project.xml` contains an extensive description of the available conf
185185
docker packaging for Docker
186186
java Java JNI binding
187187
java-msvc MSVC builds for Java JNI binding
188+
jenkins Jenkins pipeline build
188189
mingw32 Mingw32 build system
189190
nuget Packaging for NuGet
190191
python Python binding
@@ -343,6 +344,14 @@ zproject's `project.xml` contains an extensive description of the available conf
343344
<target name = "debian" />
344345
<target name = "redhat" />
345346

347+
<!-- Jenkins target creates jenkins pipeline
348+
Pipeline file is not overwriten if it exists.
349+
<target name = "jenkins">
350+
<option name = "file" value = "Jenkinsfile" />
351+
<option name = "docker" value = "zeromqorg/czmq" />
352+
</target>
353+
-->
354+
346355
<!-- In order loaded by zproject.gsl -->
347356
<bin name = "zproject.gsl" />
348357
<bin name = "zproject_projects.gsl" />
@@ -366,6 +375,7 @@ zproject's `project.xml` contains an extensive description of the available conf
366375
<bin name = "zproject_java.gsl" />
367376
<bin name = "zproject_java_lib.gsl" />
368377
<bin name = "zproject_java_msvc.gsl" />
378+
<bin name = "zproject_jenkins.gsl" />
369379
<bin name = "zproject_lua_ffi.gsl" />
370380
<bin name = "zproject_mingw32.gsl" />
371381
<bin name = "zproject_nodejs.gsl" />

‎zproject_jenkins.gsl

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Generate spec file for project
2+
#
3+
# This is a code generator built using the iMatix GSL code generation
4+
# language. See https://github.com/imatix/gsl for details.
5+
#
6+
# Copyright (c) the Contributors as noted in the AUTHORS file.
7+
# This file is part of zproject.
8+
#
9+
# This Source Code Form is subject to the terms of the Mozilla Public
10+
# License, v. 2.0. If a copy of the MPL was not distributed with this
11+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
12+
13+
register_target ("jenkins", "pipeline CI script for jenkins")
14+
15+
.macro target_jenkins
16+
.if defined (project.jenkins_file)
17+
. jenkinsfile = project.jenkins_file
18+
.else
19+
. jenkinsfile = 'Jenkinsfile'
20+
.endif
21+
.if file.exists (jenkinsfile)
22+
. echo "NOT regenerating an existing Jenkins file"
23+
.else
24+
. output jenkinsfile
25+
/*
26+
$(project.name) - $(project.description?'':)
27+
28+
. for project.license
29+
$(string.trim (license.):block )
30+
. endfor
31+
*/
32+
33+
pipeline {
34+
.if defined (project.jenkins_docker)
35+
agent {
36+
docker { image '$(project.jenkins_docker)' }
37+
}
38+
.else
39+
agent any
40+
.endif
41+
triggers {
42+
pollSCM 'H/5 * * * *'
43+
}
44+
stages {
45+
stage ('compile') {
46+
steps {
47+
sh './autogen.sh'
48+
sh './configure'
49+
sh 'make'
50+
}
51+
}
52+
stage ('check') {
53+
steps {
54+
timeout (time: 5, unit: MINUTES) {
55+
sh 'make check'
56+
}
57+
}
58+
}
59+
stage ('memcheck') {
60+
steps {
61+
timeout (time: 5, unit: MINUTES) {
62+
sh 'make memcheck'
63+
}
64+
}
65+
}
66+
}
67+
post {
68+
success {
69+
script {
70+
if (currentBuild.getPreviousBuild()?.result != 'SUCCESS') {
71+
// Uncomment desired notification
72+
73+
//slackSend (color: "#008800", message: "Build ${env.JOB_NAME} is back to normal.")
74+
//emailext (to: "qa@example.com", subject: "Build ${env.JOB_NAME} is back to normal.", body: "Build ${env.JOB_NAME} is back to normal.")
75+
}
76+
}
77+
}
78+
failure {
79+
// Uncomment desired notification
80+
// Section must not be empty, you can delete the sleep once you set notification
81+
sleep 1
82+
//slackSend (color: "#AA0000", message: "Build ${env.BUILD_NUMBER} of ${env.JOB_NAME} ${currentBuild.result} (<${env.BUILD_URL}|Open>)")
83+
//emailext (to: "qa@example.com", subject: "Build ${env.JOB_NAME} failed!", body: "Build ${env.BUILD_NUMBER} of ${env.JOB_NAME} ${currentBuild.result}\\nSee ${env.BUILD_URL}")
84+
}
85+
}
86+
}
87+
.endif
88+
.endmacro

0 commit comments

Comments
 (0)
Please sign in to comment.