java-spring-microservice/Jenkinsfile
Jim Nicholson c13601e0ad
Some checks failed
Homelab/java-spring-microservice/pipeline/head There was a failure building this commit
No cache here
2021-12-23 14:21:43 -08:00

55 lines
1.3 KiB
Groovy

def label = "servicedemo-${UUID.randomUUID().toString()}"
podTemplate(label: label, containers: [
containerTemplate(
name: 'maven',
image: 'maven:3.8.4-openjdk-11',
command: 'sleep',
args: '30d'
),
containerTemplate(
name: 'kaniko',
image: 'gcr.io/kaniko-project/executor:debug',
command: 'sleep',
args: '99d'
)
], workspaceVolume: dynamicPVC()) {
node(label) {
stage('Checkout') {
checkout scm
GIT_HASH = sh (
script: 'git rev-parse --short HEAD',
returnStdout: true
)
container('maven') {
stage('Build') {
sh '''
mvn clean package -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
'''
}
stage('Archive') {
archiveArtifacts artifacts: 'target/*.jar', followSymlinks: false
}
}
container('kaniko') {
stage('Image') {
ansiColor('xterm') {
sh "/kaniko/executor \
-f `pwd`/Dockerfile \
-c `pwd` \
--insecure \
--skip-tls-verify \
--no-push \
--tarPath ./target/servicedemo.image.tar"
}
}
stage('Archive') {
archiveArtifacts artifacts: 'target/*.tar', followSymlinks: false
}
}
}
}
}