diff --git a/podman.mk b/podman.mk index f3f7b48..55cff91 100644 --- a/podman.mk +++ b/podman.mk @@ -1,12 +1,19 @@ # Parse version from latest git semver tag BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) -GIT_TAG=$(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null) -TAG ?= $(shell echo $(GIT_TAG) | awk -F '-' '{ print $$1 "-" $$2 }' | sed -e 's/-$$//') -# EXTRA_TAGS supposed to be set at the caller, eg. $(shell echo $(TAG) | awk -F '.' '{ print $$1 "." $$2 }') +GIT_TAG := $(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null) +TAG := $(GIT_TAG) + +# append branch name to tag if NOT main nor master +ifeq (,$(filter main master, $(BRANCH))) + TAG = $(GIT_TAG)-$(BRANCH) +endif + +# optionally set by the caller +EXTRA_TAGS := ARCH := amd64 ALL_ARCHS := amd64 arm64 -_ARCH = $(or $(filter ${ARCH},${ALL_ARCHS}),$(error $$ARCH [${ARCH}] must be exactly one of ${ALL_ARCHS})) +_ARCH = $(or $(filter $(ARCH),$(ALL_ARCHS)),$(error $$ARCH [$(ARCH)] must be exactly one of "$(ALL_ARCHS)")) ifneq ($(TRIVY_REMOTE),) TRIVY_OPTS := --server $(TRIVY_REMOTE) diff --git a/vars/buildPodman.groovy b/vars/buildPodman.groovy index ca43934..e5ecff9 100644 --- a/vars/buildPodman.groovy +++ b/vars/buildPodman.groovy @@ -10,6 +10,7 @@ def call(Map config=[:]) { stages { stage('Prepare') { steps { + // pull tags withCredentials([gitUsernamePassword(credentialsId: 'gitea-jenkins-user')]) { sh 'git fetch -q --tags ${GIT_URL}' }