|
| 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