diff --git a/build-signal.jenkins b/build-signal.jenkins index 8cf160f..388f739 100644 --- a/build-signal.jenkins +++ b/build-signal.jenkins @@ -1,6 +1,8 @@ def repository = "registry.c.test-chamber-13.lan" def repositoryCreds = "harbor-repository-creds" +def workspace +def latestTag def label = "kubernetes-${UUID.randomUUID().toString()}" def templateName = "pipeline-worker" def outputFile @@ -22,7 +24,43 @@ podTemplate( ) ) { node (label) { - def workspace = pwd() + stage ('Initalize Jenkins') { + steps { + script { + workspace = pwd() + } + } + } + + stage ('Get latest Tag') { + steps { + container ('alpine') { + script { + sh """ + if ! command -v curl &> /dev/null; then + apk add --no-cache curl + fi + if ! command -v jq &> /dev/null; then + apk add --no-cache jq + fi + """ + latestTag = sh ( + script: """ + curl \ + --location \ + --silent \ + --fail \ + --request GET \ + --url https://api.github.com/repos/signalapp/Signal-Desktop/releases/latest | \ + jq -r 'select(.prerelease == false) | .tag_name[1:]' + """, + returnStdout: true + ).trim() + println("Latest Tag: " + latestTag) + } + } + } + } stage ("Clone Signal") { dir("signal-desktop") { @@ -30,7 +68,7 @@ podTemplate( $class: "GitSCM", branches: [ [ - name: "refs/heads/main", + name: "refs/tags/" + latestTag, ], ], userRemoteConfigs: [