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
This commit is contained in:
Stefan Reimer 2023-08-17 09:51:15 +00:00
parent 6d421cefd1
commit 27dddfb1b7
2 changed files with 13 additions and 16 deletions

View File

@ -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 @

View File

@ -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'
}
}