Skip to content

Instantly share code, notes, and snippets.

@InfoSec812
Last active March 21, 2019 17:22
Show Gist options
  • Select an option

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

Select an option

Save InfoSec812/bd15f57792109c62bcebe3a724a4f322 to your computer and use it in GitHub Desktop.
Scaffolding A podTemplate For Jenkins
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '50'))
timeout(time: 20, unit: 'MINUTES') // If the build takes longer than 20 minutes, fail automatically
}
agent {
kubernetes {
label "zaproxy-maven-sidecars-${env.BUILD_ID}"
defaultContainer 'jenkins-slave-mvn'
yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
pod-template: jenkins-slave-sidecars
spec:
"""
}
}
}
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '50'))
timeout(time: 20, unit: 'MINUTES') // If the build takes longer than 20 minutes, fail automatically
}
agent {
kubernetes {
label "zaproxy-maven-sidecars-${env.BUILD_ID}"
defaultContainer 'jenkins-slave-mvn'
yaml """ ## Kubernetest/OpenShift YAML to define the Pod
apiVersion: v1
kind: Pod
metadata:
labels:
pod-template: jenkins-slave-sidecars
spec:
containers:
- name: jenkins-slave-mvn
tty: true
command:
- cat
- name: jenkins-slave-zap
tty: true
command:
- cat
"""
}
}
}
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '50'))
timeout(time: 20, unit: 'MINUTES') // If the build takes longer than 20 minutes, fail automatically
}
agent {
kubernetes {
label "zaproxy-maven-sidecars-${env.BUILD_ID}"
defaultContainer 'jenkins-slave-mvn'
yaml """ ## Kubernetest/OpenShift YAML to define the Pod
apiVersion: v1
kind: Pod
metadata:
labels:
pod-template: jenkins-slave-sidecars
spec:
containers:
- name: jenkins-slave-mvn
tty: true
command:
- cat
env:
- name: SOME_ENV_VAR
value: 'SomeValue'
- name: jenkins-slave-zap
tty: true
command:
- cat
env:
- name: SOME_ENV_VAR
value: 'SomeValue'
"""
}
}
}
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '50'))
timeout(time: 20, unit: 'MINUTES') // If the build takes longer than 20 minutes, fail automatically
}
agent {
kubernetes {
label "zaproxy-maven-sidecars-${env.BUILD_ID}"
defaultContainer 'jenkins-slave-mvn'
yaml """ ## Kubernetest/OpenShift YAML to define the Pod
apiVersion: v1
kind: Pod
metadata:
labels:
pod-template: jenkins-slave-sidecars
spec:
volumes: ## Expose some volumes to be used in the containers
- name: reports-storage
emptyDir: {}
- name: git-repo
emptyDir: {}
containers:
- name: jenkins-slave-mvn
tty: true
command:
- cat
env:
- name: SOME_ENV_VAR
value: 'SomeValue'
volumeMounts:
- name: reports-storage
mountPath: /tmp/reports
- name: git-repo
mountPath: /project/myproject
- name: jenkins-slave-zap
tty: true
command:
- cat
env:
- name: SOME_ENV_VAR
value: 'SomeValue'
volumeMounts:
- name: reports-storage
mountPath: /tmp/reports
- name: git-repo
mountPath: /project/myproject
"""
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment