Created
September 23, 2020 15:26
-
-
Save rkivisto/6fc98dbbc194882d2608edf967d2bd08 to your computer and use it in GitHub Desktop.
Revisions
-
rkivisto created this gist
Sep 23, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,73 @@ Upstream: pipeline { agent { kubernetes { // Rather than inline YAML, in a multibranch Pipeline you could use: yamlFile 'jenkins-pod.yaml' // Or, to avoid YAML: // containerTemplate { // name 'shell' // image 'ubuntu' // command 'sleep' // args 'infinity' // } yaml ''' apiVersion: v1 kind: Pod spec: containers: - name: shell image: ubuntu command: - sleep args: - infinity ''' // Can also wrap individual steps: // container('shell') { // sh 'hostname' // } defaultContainer 'shell' } } stages { stage('Main') { steps { sh 'cat /etc/os-release' build job: 'downstream', parameters: [string(name: 'IMAGE', value: 'ubuntu:18.04')] } } } } Downstream: pipeline { parameters { string defaultValue: 'ubuntu:latest', description: 'Docker image and tag to use', name: 'IMAGE', trim: true } agent { kubernetes { yaml """ apiVersion: v1 kind: Pod spec: containers: - name: shell image: $IMAGE command: - sleep args: - infinity """ defaultContainer 'shell' } } stages { stage('Main') { steps { sh 'cat /etc/os-release' } } } }