Created
April 30, 2022 10:06
-
-
Save sasaken555/05b0ad6d0a852604aaf4f41f65069f2d to your computer and use it in GitHub Desktop.
Declarative Pipeline that use OpenShift/Kubernetes Pod as agent
This file contains 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
// 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