Last active
March 6, 2019 13:14
-
-
Save InfoSec812/76d4ba59c85f924d65abc8946bebd291 to your computer and use it in GitHub Desktop.
Load podTemplate from K8s ConfigMap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Pull the configmap from the K8 API using the Jenkins service account and store it in the podTemplateYaml variable | |
| def podTemplateYaml = '' | |
| openshift.withCluster() { | |
| openshift.withProject() { | |
| cmsel = opeshift.selector("configmap", [role: 'jenkins-slave' ]) | |
| cmsel.watch { | |
| podTemplateYaml = it.object().data[bw-maven] | |
| } | |
| } | |
| } | |
| pipeline { | |
| agent { | |
| kubernetes { | |
| label "zaproxy-maven-sidecars-${env.BUILD_ID}" | |
| defaultContainer 'jenkins-slave-mvn' | |
| yaml podTemplateYaml // Use the podTemplateYaml variable HERE to define the agent in Jenkins | |
| } | |
| } | |
| options { | |
| timeout(time: 15, unit: 'MINUTES') | |
| } | |
| environment { | |
| PROJECT_NAME = 'adjective-service' | |
| } | |
| triggers { | |
| gitlab( | |
| triggerOnPush: true, | |
| triggerOnMergeRequest: true, | |
| branchFilterType: 'NameBasedFilter', | |
| includeBranchesSpec: 'master', | |
| addVoteOnMergeRequest: true, | |
| triggerOnNoteRequest: false, | |
| addNoteOnMergeRequest: true, | |
| acceptMergeRequestOnSuccess: false | |
| ) | |
| } | |
| // Stages and steps here. | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment