Skip to content

Instantly share code, notes, and snippets.

@sasaken555
Created April 30, 2022 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasaken555/05b0ad6d0a852604aaf4f41f65069f2d to your computer and use it in GitHub Desktop.
Save sasaken555/05b0ad6d0a852604aaf4f41f65069f2d to your computer and use it in GitHub Desktop.
Declarative Pipeline that use OpenShift/Kubernetes Pod as agent
// Uses Declarative syntax to run commands inside a container.
pipeline {
agent {
kubernetes {
cloud 'openshift'
defaultContainer 'maven'
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: jnlp
image: jenkins/inbound-agent:4.11-1-jdk11
volumeMounts:
- name: home-volume
mountPath: /home/jenkins
env:
- name: HOME
value: /home/jenkins
- name: maven
image: public.ecr.aws/docker/library/maven:3.8.5-jdk-8
command:
- sleep
args:
- infinity
volumeMounts:
- name: home-volume
mountPath: /home/jenkins
env:
- name: HOME
value: /home/jenkins
- name: MAVEN_OPTS
value: -Duser.home=/home/jenkins
volumes:
- name: home-volume
emptyDir: {}
'''
}
}
stages {
stage('Build and Test') {
steps {
git branch: 'main', url: 'https://github.com/OpenLiberty/sample-getting-started.git'
sh 'mvn clean package -B -ntp -DskipTests'
archiveArtifacts artifacts: '**/target/*.war'
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment