Skip to content

Instantly share code, notes, and snippets.

@InfoSec812
Last active March 6, 2019 13:14
Show Gist options
  • Select an option

  • Save InfoSec812/76d4ba59c85f924d65abc8946bebd291 to your computer and use it in GitHub Desktop.

Select an option

Save InfoSec812/76d4ba59c85f924d65abc8946bebd291 to your computer and use it in GitHub Desktop.
Load podTemplate from K8s ConfigMap
// 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