Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- [#170] Fix hanging scripts that create and remove temporary admins
- backport to redmine 5

## [v5.1.8-4] - 2025-11-27
### Fixed
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ RUN set -eux -o pipefail \
&& rm -rf /root/* /tmp/* $(gem env gemdir)/cache \
&& apk --purge del /.build-deps \
&& rm -rf /var/cache/apk/* \
&& apk add ruby-irb
&& apk add ruby-irb \
&& chown "${USER}":"${USER}" "${WORKDIR}/Gemfile.lock"

WORKDIR ${WORKDIR}

Expand Down
7 changes: 5 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!groovy
@Library(['github.com/cloudogu/ces-build-lib@4.2.0', 'github.com/cloudogu/dogu-build-lib@v3.2.0'])
@Library(['github.com/cloudogu/ces-build-lib@5.1.0', 'github.com/cloudogu/dogu-build-lib@v3.5.1'])
import com.cloudogu.ces.cesbuildlib.*
import com.cloudogu.ces.dogubuildlib.*

Expand All @@ -12,6 +12,7 @@ node('vagrant') {
Git git = new Git(this, "cesmarvin")
git.committerName = 'cesmarvin'
git.committerEmail = 'cesmarvin@cloudogu.com'
Makefile makefile = new Makefile(this)
GitFlow gitflow = new GitFlow(this, git)
GitHub github = new GitHub(this, git)
Changelog changelog = new Changelog(this)
Expand Down Expand Up @@ -139,7 +140,9 @@ node('vagrant') {
String releaseVersion = git.getSimpleBranchName();

stage('Finish Release') {
gitflow.finishRelease(releaseVersion)
productionReleaseBranch = makefile.determineGitFlowMainBranch()
developmentBranch = makefile.determineGitFlowDevelopBranch()
gitflow.finishRelease(releaseVersion, productionReleaseBranch, developmentBranch)
}

stage('Push Dogu to registry') {
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
MAKEFILES_VERSION=9.9.1
MAKEFILES_VERSION=10.5.0
BASE_VERSION=5.1.8

.DEFAULT_GOAL:=dogu-release

Expand Down
10 changes: 7 additions & 3 deletions build/make/bats.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ BATS_SUPPORT=$(BATS_LIBRARY_DIR)/bats-support
BATS_FILE=$(BATS_LIBRARY_DIR)/bats-file
BATS_BASE_IMAGE?=bats/bats
BATS_CUSTOM_IMAGE?=cloudogu/bats
BATS_TAG?=1.11.0
BATS_TAG?=1.12.0
BATS_DIR=build/make/bats
BATS_WORKDIR="${WORKDIR}"/"${BATS_DIR}"

Expand All @@ -18,15 +18,19 @@ unit-test-shell: unit-test-shell-$(ENVIRONMENT)

$(BATS_ASSERT):
@git clone --depth 1 https://github.com/bats-core/bats-assert $@
@rm -rf $@/.git

$(BATS_MOCK):
@git clone --depth 1 https://github.com/grayhemp/bats-mock $@
@rm -rf $@/.git

$(BATS_SUPPORT):
@git clone --depth 1 https://github.com/bats-core/bats-support $@
@rm -rf $@/.git

$(BATS_FILE):
@git clone --depth 1 https://github.com/bats-core/bats-file $@
@rm -rf $@/.git

$(BASH_SRC):
BASH_SRC:=$(shell find "${WORKDIR}" -type f -name "*.sh")
Expand All @@ -49,10 +53,10 @@ unit-test-shell-local: $(BASH_SRC) $(PASSWD) $(ETCGROUP) $(HOME_DIR) buildTestIm
"${BATS_DIR}"/customBatsEntrypoint.sh make unit-test-shell-generic-no-junit

unit-test-shell-generic:
@bats --formatter junit --output ${BASH_TEST_REPORT_DIR} ${TESTS_DIR}
@bats --report-formatter junit --formatter junit --output ${BASH_TEST_REPORT_DIR} ${TESTS_DIR}

unit-test-shell-generic-no-junit:
@bats ${TESTS_DIR}
@bats --report-formatter junit --output ${BASH_TEST_REPORT_DIR} ${TESTS_DIR}

.PHONY buildTestImage:
buildTestImage:
Expand Down
2 changes: 1 addition & 1 deletion build/make/bats/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG BATS_BASE_IMAGE
ARG BATS_TAG

FROM ${BATS_BASE_IMAGE:-bats/bats}:${BATS_TAG:-1.11.0}
FROM ${BATS_BASE_IMAGE:-bats/bats}:${BATS_TAG:-1.12.0}

# Make bash more findable by scripts and tests
RUN apk add make git bash
Expand Down
9 changes: 8 additions & 1 deletion build/make/bats/customBatsEntrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@ set -o errexit
set -o nounset
set -o pipefail

"$@"
targetReportDir="${PWD}"/target/shell_test_reports
uidgid=1000:1000
exitcode=0
"$@" || exitcode=$?
echo "Resetting file ownership to ${uidgid} in ${targetReportDir}/"
chown -R ${uidgid} "${targetReportDir}"/*
echo "exiting with code ${exitcode}"
exit ${exitcode}
2 changes: 1 addition & 1 deletion build/make/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ADDITIONAL_LDFLAGS?=-extldflags -static
LDFLAGS?=-ldflags "$(ADDITIONAL_LDFLAGS) -X main.Version=$(VERSION) -X main.CommitID=$(COMMIT_ID)"
GOIMAGE?=golang
GOTAG?=1.24
GOTAG?=1.25
GOOS?=linux
GOARCH?=amd64
PRE_COMPILE?=
Expand Down
12 changes: 7 additions & 5 deletions build/make/k8s-component.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
COMPONENT_DEV_VERSION?=${VERSION}-dev
COMPONENT_BUILD_VERSION := $(shell date +%s)
COMPONENT_DEV_VERSION?=${VERSION}-dev.${COMPONENT_BUILD_VERSION}

include ${BUILD_DIR}/make/k8s.mk

Expand All @@ -15,8 +16,9 @@ HELM_RELEASE_TGZ=${HELM_TARGET_DIR}/${ARTIFACT_ID}-${VERSION}.tgz
HELM_DEV_RELEASE_TGZ=${HELM_TARGET_DIR}/${ARTIFACT_ID}-${COMPONENT_DEV_VERSION}.tgz
HELM_ARTIFACT_NAMESPACE?=k8s
ifeq (${RUNTIME_ENV}, remote)
HELM_ARTIFACT_NAMESPACE?=testing/k8s
HELM_ARTIFACT_NAMESPACE=testing/k8s
endif
$(info HELM_ARTIFACT_NAMESPACE=$(HELM_ARTIFACT_NAMESPACE))

K8S_RESOURCE_COMPONENT ?= "${K8S_RESOURCE_TEMP_FOLDER}/component-${ARTIFACT_ID}-${VERSION}.yaml"
K8S_RESOURCE_COMPONENT_CR_TEMPLATE_YAML ?= $(BUILD_DIR)/make/k8s-component.tpl
Expand Down Expand Up @@ -93,10 +95,10 @@ helm-reinstall: helm-delete helm-apply ## Uninstalls the current helm chart and
.PHONY: helm-chart-import
helm-chart-import: ${CHECK_VAR_TARGETS} helm-generate helm-package ${IMAGE_IMPORT_TARGET} ## Imports the currently available chart into the cluster-local registry.
@if [[ ${STAGE} == "development" ]]; then \
echo "Import ${HELM_DEV_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}..."; \
echo "Import ${HELM_DEV_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
${BINARY_HELM} push ${HELM_DEV_RELEASE_TGZ} oci://${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
else \
echo "Import ${HELM_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}..."; \
echo "Import ${HELM_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
${BINARY_HELM} push ${HELM_RELEASE_TGZ} oci://${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
fi
@echo "Done."
Expand Down Expand Up @@ -142,7 +144,7 @@ ${K8S_RESOURCE_COMPONENT_CR_TEMPLATE_YAML}: ${K8S_RESOURCE_TEMP_FOLDER}
fi

.PHONY: component-apply
component-apply: check-k8s-namespace-env-var ${COMPONENT_PRE_APPLY_TARGETS} ${IMAGE_IMPORT_TARGET} helm-generate helm-chart-import component-generate ## Applies the component yaml resource to the actual defined context.
component-apply: isProduction check-k8s-namespace-env-var ${COMPONENT_PRE_APPLY_TARGETS} ${IMAGE_IMPORT_TARGET} helm-generate helm-chart-import component-generate ## Applies the component yaml resource to the actual defined context.
@kubectl apply -f "${K8S_RESOURCE_COMPONENT}" --namespace="${NAMESPACE}" --context="${KUBE_CONTEXT_NAME}"
@echo "Done."

Expand Down
9 changes: 5 additions & 4 deletions build/make/k8s-crd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ ifeq ($(APPEND_CRD_SUFFIX), true)
else ifeq ($(APPEND_CRD_SUFFIX), false)
ARTIFACT_CRD_ID = $(ARTIFACT_ID)
endif
DEV_CRD_VERSION ?= ${VERSION}-dev
CRD_BUILD_VERSION := $(shell date +%s).$(TIMESTAMP)
DEV_CRD_VERSION ?= ${VERSION}-dev.${COMPONENT_BUILD_VERSION}
HELM_CRD_SOURCE_DIR ?= ${WORKDIR}/k8s/helm-crd
HELM_CRD_TARGET_DIR ?= $(K8S_RESOURCE_TEMP_FOLDER)/helm-crd
HELM_CRD_RELEASE_TGZ = ${HELM_CRD_TARGET_DIR}/${ARTIFACT_CRD_ID}-${VERSION}.tgz
Expand Down Expand Up @@ -89,10 +90,10 @@ ${HELM_CRD_RELEASE_TGZ}: ${BINARY_HELM} crd-helm-generate ## Generates and packa
.PHONY: crd-helm-chart-import
crd-helm-chart-import: ${CHECK_VAR_TARGETS} check-k8s-artifact-id crd-helm-generate crd-helm-package ## Imports the currently available Helm CRD chart into the cluster-local registry.
@if [[ ${STAGE} == "development" ]]; then \
echo "Import ${HELM_CRD_DEV_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}..."; \
echo "Import ${HELM_CRD_DEV_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
${BINARY_HELM} push ${HELM_CRD_DEV_RELEASE_TGZ} oci://${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
else \
echo "Import ${HELM_CRD_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}..."; \
echo "Import ${HELM_CRD_RELEASE_TGZ} into K8s cluster ${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE}..."; \
${BINARY_HELM} push ${HELM_CRD_RELEASE_TGZ} oci://${CES_REGISTRY_HOST}/${HELM_ARTIFACT_NAMESPACE} ${BINARY_HELM_ADDITIONAL_PUSH_ARGS}; \
fi
@echo "Done."
Expand All @@ -111,7 +112,7 @@ crd-component-generate: ${K8S_RESOURCE_TEMP_FOLDER} ## Generate the CRD componen
fi

.PHONY: crd-component-apply
crd-component-apply: check-k8s-namespace-env-var crd-helm-chart-import crd-component-generate ## Applies the CRD component YAML resource to the actual defined context.
crd-component-apply: isProduction check-k8s-namespace-env-var crd-helm-chart-import crd-component-generate ## Applies the CRD component YAML resource to the actual defined context.
@kubectl apply -f "${K8S_RESOURCE_CRD_COMPONENT}" --namespace="${NAMESPACE}" --context="${KUBE_CONTEXT_NAME}"
@echo "Done."

Expand Down
13 changes: 12 additions & 1 deletion build/make/k8s.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BINARY_YQ_4_VERSION?=v4.40.3
BINARY_HELM = $(UTILITY_BIN_PATH)/helm
BINARY_HELM_VERSION?=v3.13.0
CONTROLLER_GEN = $(UTILITY_BIN_PATH)/controller-gen
CONTROLLER_GEN_VERSION?=v0.14.0
CONTROLLER_GEN_VERSION?=v0.19.0

# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
Expand Down Expand Up @@ -203,3 +203,14 @@ envtest: ${ENVTEST} ## Download envtest-setup locally if necessary.

${ENVTEST}:
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)

.PHONY: isProduction
isProduction:
@if [[ "${STAGE}" == "production" ]]; then \
echo "Command executed in production stage. Aborting."; \
exit 1; \
else \
echo "Command executed in development stage. Continuing."; \
fi


8 changes: 5 additions & 3 deletions build/make/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ else
CURRENT_TOOL_VERSION=$(get_current_version_by_makefile)
fi

BASE_VERSION=$(get_base_version_by_makefile)

NEW_RELEASE_VERSION="$(read_new_version)"

validate_new_version "${NEW_RELEASE_VERSION}"
if [[ -n "${DRY_RUN}" ]]; then
start_dry_run_release "${NEW_RELEASE_VERSION}"
else
start_git_flow_release "${NEW_RELEASE_VERSION}"
start_git_flow_release "${NEW_RELEASE_VERSION}" "${BASE_VERSION}"
fi

update_versions "${NEW_RELEASE_VERSION}"
Expand All @@ -60,9 +62,9 @@ update_releasenotes "${NEW_RELEASE_VERSION}"
show_diff

if [[ -n "${DRY_RUN}" ]]; then
abort_dry_run_release "${NEW_RELEASE_VERSION}"
abort_dry_run_release "${NEW_RELEASE_VERSION}" "${BASE_VERSION}"
else
finish_release_and_push "${CURRENT_TOOL_VERSION}" "${NEW_RELEASE_VERSION}"
finish_release_and_push "${CURRENT_TOOL_VERSION}" "${NEW_RELEASE_VERSION}" "${BASE_VERSION}"
fi

echo "=====Finished Release process====="
71 changes: 59 additions & 12 deletions build/make/release_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ get_current_version_by_makefile() {
grep '^VERSION=[0-9[:alpha:].-]*$' Makefile | sed s/VERSION=//g
}

get_base_version_by_makefile() {
BASE_VERSION=$(grep '^BASE_VERSION=[0-9[:alpha:].-]*$' Makefile | sed s/BASE_VERSION=//g)
echo "${BASE_VERSION}"
}

get_current_version_by_dogu_json() {
jq ".Version" --raw-output dogu.json
}
Expand Down Expand Up @@ -52,24 +57,47 @@ validate_new_version() {

start_git_flow_release() {
local NEW_RELEASE_VERSION="${1}"
local BASE_RELEASE_VERSION="${2}"
local BASE_DEV_BRANCH_NAME

# Do gitflow
git flow init --defaults --force

local mainBranchExists
mainBranchExists="$(git show-ref refs/remotes/origin/main || echo "")"
if [ -n "$mainBranchExists" ]; then
echo 'Using "main" branch for production releases'
git flow config set master main
git checkout main
git pull origin main
if [[ -z "$BASE_RELEASE_VERSION" ]]; then
echo "BASE_RELEASE_VERSION variable is empty"
if [ -n "$mainBranchExists" ]; then
echo 'Using "main" branch for production releases'
git flow config set master main
git checkout main
git pull origin main
else
echo 'Using "master" branch for production releases'
git checkout master
git pull origin master
fi
BASE_DEV_BRANCH_NAME="develop"
else
echo 'Using "master" branch for production releases'
git checkout master
git pull origin master
echo "BASE_RELEASE_VERSION variable is not empty"
if [[ ${NEW_RELEASE_VERSION} != ${BASE_RELEASE_VERSION}* ]]; then
echo "ERROR: Release version (${NEW_RELEASE_VERSION}) does not start with base version (${BASE_RELEASE_VERSION})"
exit 1
fi

BASE_MAIN_BRANCH_NAME="${BASE_RELEASE_VERSION}/main"
echo "Using ${BASE_MAIN_BRANCH_NAME} branch for production releases"
git flow config set master ${BASE_MAIN_BRANCH_NAME}
git checkout ${BASE_MAIN_BRANCH_NAME}
git pull origin ${BASE_MAIN_BRANCH_NAME}
BASE_DEV_BRANCH_NAME="${BASE_RELEASE_VERSION}/develop"
fi

git checkout develop
git pull origin develop
git flow config set develop ${BASE_DEV_BRANCH_NAME}

git checkout ${BASE_DEV_BRANCH_NAME}
git pull origin ${BASE_DEV_BRANCH_NAME}
git flow config
git flow release start v"${NEW_RELEASE_VERSION}"
}

Expand All @@ -81,8 +109,17 @@ start_dry_run_release() {

abort_dry_run_release() {
local NEW_RELEASE_VERSION="${1}"
local BASE_RELEASE_VERSION="${2}"

local BASE_DEV_BRANCH_NAME

if [[ -z "$BASE_RELEASE_VERSION" ]]; then
BASE_DEV_BRANCH_NAME="develop"
else
BASE_DEV_BRANCH_NAME="${BASE_RELEASE_VERSION}/develop"
fi

git checkout develop
git checkout ${BASE_DEV_BRANCH_NAME}
git branch -D dryrun/v"${NEW_RELEASE_VERSION}"
}

Expand Down Expand Up @@ -302,12 +339,22 @@ show_diff() {
finish_release_and_push() {
local CURRENT_VERSION="${1}"
local NEW_RELEASE_VERSION="${2}"
local BASE_RELEASE_VERSION="${3}"

# Push changes and delete release branch
wait_for_ok "Upgrade from version v${CURRENT_VERSION} to version v${NEW_RELEASE_VERSION} finished. Should the changes be pushed?"
git push origin release/v"${NEW_RELEASE_VERSION}"

echo "Switching back to develop and deleting branch release/v${NEW_RELEASE_VERSION}..."
git checkout develop

local BASE_DEV_BRANCH_NAME

if [[ -z "$BASE_RELEASE_VERSION" ]]; then
BASE_DEV_BRANCH_NAME="develop"
else
BASE_DEV_BRANCH_NAME="${BASE_RELEASE_VERSION}/develop"
fi

git checkout ${BASE_DEV_BRANCH_NAME}
git branch -D release/v"${NEW_RELEASE_VERSION}"
}
8 changes: 4 additions & 4 deletions build/make/static-analysis.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

STATIC_ANALYSIS_DIR=$(TARGET_DIR)/static-analysis
GOIMAGE?=golang
GOTAG?=1.24
GOTAG?=1.25
CUSTOM_GO_MOUNT?=-v /tmp:/tmp

REVIEW_DOG=$(TMP_DIR)/bin/reviewdog
LINT=$(TMP_DIR)/bin/golangci-lint
LINT_VERSION?=v1.64.8
LINT_VERSION?=v2.5.0
# ignore tests and mocks
LINTFLAGS=--tests=false --exclude-files="^.*_mock.go$$" --exclude-files="^.*/mock.*.go$$" --timeout 10m --issues-exit-code 0
LINTFLAGS=--tests=false --timeout 10m --issues-exit-code 0
ADDITIONAL_LINTER=-E bodyclose -E containedctx -E contextcheck -E decorder -E dupl -E errname -E forcetypeassert -E funlen -E unparam

.PHONY: static-analysis
Expand Down Expand Up @@ -47,7 +47,7 @@ $(STATIC_ANALYSIS_DIR)/static-analysis.log: $(STATIC_ANALYSIS_DIR)

$(STATIC_ANALYSIS_DIR)/static-analysis-cs.log: $(STATIC_ANALYSIS_DIR)
@echo "run static analysis with export to checkstyle format"
@$(LINT) $(LINTFLAGS) run --out-format=checkstyle ./... $(ADDITIONAL_LINTER) > $@
@$(LINT) $(LINTFLAGS) --output.checkstyle.path stdout run ./... $(ADDITIONAL_LINTER) > $@

$(STATIC_ANALYSIS_DIR): $(LINT)
@mkdir -p $(STATIC_ANALYSIS_DIR)
Expand Down
Loading