From f117f82ec0d7b033f6ee7b99cc70d57dee4a1943 Mon Sep 17 00:00:00 2001 From: Jim Nicholson Date: Wed, 19 Jan 2022 18:11:14 -0800 Subject: [PATCH] Add in Jenkinsfile --- .groovylintrc.json | 8 ++++++++ Jenkinsfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .groovylintrc.json create mode 100644 Jenkinsfile diff --git a/.groovylintrc.json b/.groovylintrc.json new file mode 100644 index 0000000..481a6cb --- /dev/null +++ b/.groovylintrc.json @@ -0,0 +1,8 @@ +{ + "extends": "recommended", + "rules": { + "CompileStatic": { + "enabled": false + } + } +} \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..243de64 --- /dev/null +++ b/Jenkinsfile @@ -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 + } + } + } +}