Skip to content

Commit

Permalink
Create Jenkinsfile-kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
crown2012 authored Aug 24, 2023
1 parent b34cc1b commit a945e07
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions Jenkinsfile-kubernetes
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: maven
image: maven:3.8.6-openjdk-8
command:
- sleep
args:
- infinity
- name: kaniko
image: gcr.io/kaniko-project/executor:debug
command:
- sleep
args:
- infinity
volumeMounts:
- name: registry-credentials
mountPath: /kaniko/.docker
volumes:
- name: registry-credentials
secret:
secretName: regcred
items:
- key: .dockerconfigjson
path: config.json
'''
}
}
stages {
stage('Checkout') {
steps {
container('maven') {
git branch: 'main', url: 'https://github.com/crown2012/source-maven-java-spring-hello-webapp.git'
}
}
}
stage('Build') {
steps {
container('maven') {
sh 'mvn clean package -DskipTests=true'
}
}
}
stage('Test') {
steps {
container('maven') {
sh 'mvn test'
}
}
}
stage('Build & Tag & Push Docker Image') {
steps {
container('kaniko') {
sh 'executor --context=dir://$WORKSPACE --destination=<IMAGE>:$BUILD_NUMBER --destination=<IMAGE>:latest'
}
}
}
}
}

0 comments on commit a945e07

Please sign in to comment.