|
| 1 | +def label = "buildpod.${env.JOB_NAME}".replaceAll(/[^A-Za-z-]+/, '-').take(62) + "p" |
| 2 | + |
| 3 | +podTemplate( |
| 4 | + name: label, |
| 5 | + label: label, |
| 6 | + containers: [ |
| 7 | + containerTemplate( |
| 8 | + name: 'build-golang', |
| 9 | + image: 'docker.io/bborbe/build-golang:1.0.0', |
| 10 | + ttyEnabled: true, |
| 11 | + command: 'cat', |
| 12 | + resourceRequestCpu: '500m', |
| 13 | + resourceRequestMemory: '500Mi', |
| 14 | + resourceLimitCpu: '2000m', |
| 15 | + resourceLimitMemory: '500Mi', |
| 16 | + ), |
| 17 | + ], |
| 18 | + volumes: [], |
| 19 | + inheritFrom: '', |
| 20 | + namespace: 'jenkins', |
| 21 | + serviceAccount: '', |
| 22 | + workspaceVolume: emptyDirWorkspaceVolume(false), |
| 23 | +) { |
| 24 | + node(label) { |
| 25 | + properties([ |
| 26 | + buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '3', numToKeepStr: '5')), |
| 27 | + pipelineTriggers([ |
| 28 | + cron('H 2 * * *'), |
| 29 | + pollSCM('H/5 * * * *'), |
| 30 | + ]), |
| 31 | + ]) |
| 32 | + try { |
| 33 | + container('build-golang') { |
| 34 | + stage('Golang Checkout') { |
| 35 | + timeout(time: 5, unit: 'MINUTES') { |
| 36 | + checkout([ |
| 37 | + $class: 'GitSCM', |
| 38 | + branches: scm.branches, |
| 39 | + doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations, |
| 40 | + extensions: scm.extensions + [[$class: 'CloneOption', noTags: false, reference: '', shallow: true]], |
| 41 | + submoduleCfg: [], |
| 42 | + userRemoteConfigs: scm.userRemoteConfigs |
| 43 | + ]) |
| 44 | + } |
| 45 | + } |
| 46 | + stage('Golang Link') { |
| 47 | + timeout(time: 5, unit: 'MINUTES') { |
| 48 | + sh """ |
| 49 | + mkdir -p /go/src/github.com/bborbe |
| 50 | + ln -s `pwd` /go/src/github.com/bborbe/webdriver |
| 51 | + """ |
| 52 | + } |
| 53 | + } |
| 54 | + stage('Golang Test') { |
| 55 | + timeout(time: 15, unit: 'MINUTES') { |
| 56 | + sh "cd /go/src/github.com/bborbe/webdriver && make test" |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + currentBuild.result = 'SUCCESS' |
| 61 | + } catch (any) { |
| 62 | + currentBuild.result = 'FAILURE' |
| 63 | + throw any //rethrow exception to prevent the build from proceeding |
| 64 | + } finally { |
| 65 | + if ('FAILURE'.equals(currentBuild.result)) { |
| 66 | + emailext( |
| 67 | + body: '${DEFAULT_CONTENT}', |
| 68 | + mimeType: 'text/html', |
| 69 | + replyTo: '$DEFAULT_REPLYTO', |
| 70 | + subject: '${DEFAULT_SUBJECT}', |
| 71 | + to: emailextrecipients([ |
| 72 | + [$class: 'CulpritsRecipientProvider'], |
| 73 | + [$class: 'RequesterRecipientProvider'] |
| 74 | + ]) |
| 75 | + ) |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | +} |
0 commit comments