Add in Jenkinsfile
Some checks failed
Homelab/ansible-playbook-runner/pipeline/head There was a failure building this commit

This commit is contained in:
Jim Nicholson 2022-01-19 18:11:14 -08:00
parent 1251f74d38
commit f117f82ec0
2 changed files with 50 additions and 0 deletions

8
.groovylintrc.json Normal file
View File

@ -0,0 +1,8 @@
{
"extends": "recommended",
"rules": {
"CompileStatic": {
"enabled": false
}
}
}

42
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env groovy
podLabel = "image-build-${UUID.randomUUID()}"
containerRegistry = 'docker.home.thejimnicholson.com/ansible-playbook-runner'
containerImage = 'ansible-playbook-runner'
podTemplate(label: podLabel, containers: [
containerTemplate(
name: 'kaniko',
image: 'gcr.io/kaniko-project/executor:debug',
command: 'sleep',
args: '30d'
)
], workspaceVolume: dynamicPVC()) {
node(podLabel) {
stage('Checkout') {
checkout scm
sh 'git fetch'
GIT_TAG = sh(
script: 'git describe --tags --always --dirty=-dirty',
returnStdout: true
).trim()
}
container('kaniko') {
stage('Image') {
ansiColor('css') {
sh "/kaniko/executor \
-f `pwd`/Dockerfile \
-c `pwd` \
--insecure \
--skip-tls-verify \
--tarPath ./${containerImage}-${GIT_TAG}.image.tar \
--destination=${containerRegistry}/${containerImage}:${GIT_HASH} \
--destination=${containerRegistry}/${containerImage}:latest"
}
}
stage('Archive') {
archiveArtifacts artifacts: '*.tar', followSymlinks: false
}
}
}
}