jenkins-lib

Jenkins shared library
git clone https://git.in0rdr.ch/jenkins-lib.git
Log | Files | Refs | README

commit 199c3c7ddd6407bc8a1224745092796fda07f57f
parent 7b39adf55b860301f48b94f182f62c6d02b1479d
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Wed,  3 Jul 2024 17:37:32 +0200

feat(updatecli): more generic class

Diffstat:
MREADME | 3++-
Msrc/BuildahBud.groovy | 2+-
Msrc/BuildahPush.groovy | 2+-
Asrc/Updatecli.groovy | 17+++++++++++++++++
Dsrc/UpdatecliDiff.groovy | 18------------------
Avars/updatecli.groovy | 47+++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 68 insertions(+), 21 deletions(-)

diff --git a/README b/README @@ -9,7 +9,8 @@ https://www.jenkins.io/doc/book/pipeline/shared-libraries/#defining-declarative- The `vars/` directory can hold files with functions or entire declarative pipelines. However, only one declarative pipeline can be executed in a single -build. +build. I.e., you cannot have two declarative pipelines defined in two different +files in the `var/` directory and call them from the same Jenkinsfile. == Library in src folder == diff --git a/src/BuildahBud.groovy b/src/BuildahBud.groovy @@ -1,5 +1,5 @@ // A class to describe the buildah bud stage -class BuildahBud { +class BuildahBud implements Serializable { private final Script script BuildahBud(Script script) { diff --git a/src/BuildahPush.groovy b/src/BuildahPush.groovy @@ -1,5 +1,5 @@ // A class to describe the buildah push stage -class BuildahPush { +class BuildahPush implements Serializable { private final Script script BuildahPush(Script script) { diff --git a/src/Updatecli.groovy b/src/Updatecli.groovy @@ -0,0 +1,17 @@ +// A class to describe the updatecli stages +class Updatecli implements Serializable { + private final Script script + + Updatecli(Script script) { + this.script = script + } + + void run(String action = 'diff') { + script.stage(action) { + script.docker.image('haproxy.lan:5000/updatecli:v0.80.0') + .inside('-u root --entrypoint=""') { + script.sh "updatecli ${action}" + } + } + } +} diff --git a/src/UpdatecliDiff.groovy b/src/UpdatecliDiff.groovy @@ -1,18 +0,0 @@ -// A class to describe the updatecli diff stage -// - https://www.updatecli.io/docs/automate/jenkins -// - https://www.updatecli.io/docs/guides/npm -class UpdatecliDiff { - private final Script script - - UpdatecliDiff(Script script) { - this.script = script - } - - void execute() { - script.stage(stageName) { - docker.image('ghcr.io/updatecli/updatecli:latest') { - sh 'updatecli diff' - } - } - } -} diff --git a/vars/updatecli.groovy b/vars/updatecli.groovy @@ -0,0 +1,47 @@ +def call() { + pipeline { + agent { + docker { + label 'podman' + image 'ghcr.io/updatecli/updatecli:latest' + //args '-u root --entrypoint=' + } + } + + stages { + stage('Check configuration update') { + steps { + script { + sh ''' + updatecli diff + ''' + } + } + } + //stage('Apply configuration update') { + // steps { + // script { + // sh ''' + // updatecli apply + // ''' + // } + // } + //} + //stage('Commit configuration update') { + // steps { + // script { + // sh ''' + // git add *.json + // git commit -m "chore(deps): bump npm dependencies" + // ''' + // } + // } + //} + } + //post { + // always { + // archiveArtifacts artifacts: 'gitleaks-report.json', fingerprint: true + // } + //} + } +}