From 27dddfb1b77bec63eb64db173601486647ef55d8 Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Thu, 17 Aug 2023 09:51:15 +0000 Subject: [PATCH] Squashed '.ci/' changes from 5023473..22ed100 22ed100 Fix custom branch docker tags 227e39f Allow custom GIT_TAG 38a9cda Debug CI pipeline 3efcc81 Debug CI pipeline git-subtree-dir: .ci git-subtree-split: 22ed10034d0a2380085b8f0680a50c2e67f6fada --- podman.mk | 20 ++++++++------------ vars/buildPodman.groovy | 9 +++++---- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/podman.mk b/podman.mk index 4a51640..b75ffb4 100644 --- a/podman.mk +++ b/podman.mk @@ -1,30 +1,26 @@ # Parse version from latest git semver tag -GIT_TAG := $(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null) +GIT_TAG ?= $(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null) +GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) -GIT_BRANCH ?= $(shell git name-rev --name-only HEAD 2>/dev/null | sed -e 's,remotes/origin/,,' -e 's/[^a-zA-Z0-9]/-/g') -# if "tags/" is in the branchname we are actually on a tag and need to use rev-parse instead -ifeq ($(findstring tags/, $(GIT_TAG)),) - GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) -endif - -TAG := $(GIT_TAG) +TAG ::= $(GIT_TAG) # append branch name to tag if NOT main nor master ifeq (,$(filter main master, $(GIT_BRANCH))) # If branch is substring of tag, omit branch name ifeq ($(findstring $(GIT_BRANCH), $(GIT_TAG)),) # only append branch name if not equal tag ifneq ($(GIT_TAG), $(GIT_BRANCH)) - TAG = $(GIT_TAG)-$(GIT_BRANCH) + # Sanitize GIT_BRANCH to allowed Docker tag character set + TAG = $(GIT_TAG)-$(shell echo $$GIT_BRANCH | sed -e 's/[^a-zA-Z0-9]/-/g') endif endif endif -ARCH := amd64 -ALL_ARCHS := amd64 arm64 +ARCH ::= amd64 +ALL_ARCHS ::= amd64 arm64 _ARCH = $(or $(filter $(ARCH),$(ALL_ARCHS)),$(error $$ARCH [$(ARCH)] must be exactly one of "$(ALL_ARCHS)")) ifneq ($(TRIVY_REMOTE),) - TRIVY_OPTS := --server $(TRIVY_REMOTE) + TRIVY_OPTS ::= --server $(TRIVY_REMOTE) endif .SILENT: ; # no need for @ diff --git a/vars/buildPodman.groovy b/vars/buildPodman.groovy index 85c7aa9..e33c2cf 100644 --- a/vars/buildPodman.groovy +++ b/vars/buildPodman.groovy @@ -10,10 +10,11 @@ def call(Map config=[:]) { stages { stage('Prepare') { steps { + // we set pull tags as project adv. options // pull tags - withCredentials([gitUsernamePassword(credentialsId: 'gitea-jenkins-user')]) { - sh 'git fetch -q --tags ${GIT_URL}' - } + //withCredentials([gitUsernamePassword(credentialsId: 'gitea-jenkins-user')]) { + // sh 'git fetch -q --tags ${GIT_URL}' + //} // Optional project specific preparations sh 'make prepare' } @@ -22,7 +23,7 @@ def call(Map config=[:]) { // Build using rootless podman stage('Build') { steps { - sh 'make build' + sh 'make build GIT_BRANCH=$GIT_BRANCH' } }