feat(ci): implement conditional git commit in ArgoApplicationVersionUpdater and update container images to ci-essentials:0.0.1
Signed-off-by: zhenyus <zhenyus@mathmast.com>
This commit is contained in:
parent
85e01c6459
commit
40f33eef9a
@ -29,20 +29,45 @@ class ArgoApplicationVersionUpdater {
|
||||
steps.writeYaml(file: valuesFile, data: data, overwrite: true)
|
||||
|
||||
steps.withCredentials([steps.usernamePassword(credentialsId: 'freeleaps-ops-credentials', passwordVariable: 'OPS_GIT_PASSWORD', usernameVariable: 'OPS_GIT_USERNAME')]) {
|
||||
// steps.sh """
|
||||
// echo "Install required tools for git..."
|
||||
// apt-get -y update && apt-get install -y --no-install-recommends git apt-transport-https ca-certificates gnupg
|
||||
// echo "Set ${workspace} as a safe directory..."
|
||||
// git config --global --add safe.directory ${workspace}
|
||||
// echo "Configure git user..."
|
||||
// git config user.name "freeleaps-gitops-bot"
|
||||
// git config user.email "gitops@mathmast.com"
|
||||
// echo "Add and commit changes..."
|
||||
// git remote add ci_origin https://${steps.env.OPS_GIT_USERNAME}:${steps.env.OPS_GIT_PASSWORD}@dev.azure.com/freeleaps/freeleaps-ops/_git/freeleaps-ops
|
||||
// git add ${valuesFile}
|
||||
// git commit -m "ci(bump): bump ${component.name} image version for ${environmentSlug} to ${steps.env.BUILD_IMAGE_VERSION}"
|
||||
// echo "Push changes to freeleaps-ops repository..."
|
||||
// git push ci_origin HEAD:master
|
||||
// echo "Done."
|
||||
// """
|
||||
steps.sh """
|
||||
echo "Install required tools for git..."
|
||||
apt-get -y update && apt-get install -y --no-install-recommends git apt-transport-https ca-certificates gnupg
|
||||
echo "Set ${workspace} as a safe directory..."
|
||||
git config --global --add safe.directory ${workspace}
|
||||
|
||||
echo "Configure git user..."
|
||||
git config user.name "freeleaps-gitops-bot"
|
||||
git config user.email "gitops@mathmast.com"
|
||||
|
||||
echo "Add and commit changes..."
|
||||
git remote add ci_origin https://${steps.env.OPS_GIT_USERNAME}:${steps.env.OPS_GIT_PASSWORD}@dev.azure.com/freeleaps/freeleaps-ops/_git/freeleaps-ops
|
||||
|
||||
git add ${valuesFile}
|
||||
|
||||
if ! git diff --cached --quiet; then
|
||||
git commit -m "ci(bump): bump ${component.name} image version for ${environmentSlug} to ${steps.env.BUILD_IMAGE_VERSION}"
|
||||
echo "Detected changes, commit created."
|
||||
else
|
||||
echo "No changes detected, skipping commit."
|
||||
fi
|
||||
|
||||
echo "Push changes to freeleaps-ops repository..."
|
||||
git push ci_origin HEAD:master
|
||||
|
||||
echo "Done."
|
||||
"""
|
||||
steps.log.info("ArgoApplicationVersionUpdater", "[${environmentSlug}] ${component.name} image version bump to ${steps.env.BUILD_IMAGE_VERSION}")
|
||||
|
||||
@ -27,10 +27,10 @@ class SemanticReleasingExecutor {
|
||||
steps.withCredentials([steps.usernamePassword(credentialsId: credentialsId, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
|
||||
steps.env.GIT_CREDENTIALS = "${steps.env.GIT_USERNAME}:${steps.env.GIT_PASSWORD}"
|
||||
steps.log.info("SemanticReleasingExecutor", "Installing semantic-release requirements...")
|
||||
steps.sh "apt-get -y update && apt-get install -y --no-install-recommends git apt-transport-https ca-certificates curl wget gnupg"
|
||||
// steps.sh "apt-get -y update && apt-get install -y --no-install-recommends git apt-transport-https ca-certificates curl wget gnupg"
|
||||
steps.writeFile file: '.releaserc.json', text: steps.libraryResource(config)
|
||||
steps.log.info("SemanticReleasingExecutor", "Installing semantic-release plugins...")
|
||||
steps.sh "npm install -g ${plugins.join(' ')}"
|
||||
// steps.sh "npm install -g ${plugins.join(' ')}"
|
||||
steps.sh "git config --global --add safe.directory ${steps.env.workroot}"
|
||||
steps.env.GIT_LOCAL_BRANCH = "${branch}"
|
||||
steps.sh "semantic-release --debug"
|
||||
|
||||
@ -329,7 +329,7 @@ spec:
|
||||
containers: [
|
||||
containerTemplate(
|
||||
name: 'semantic-releasing',
|
||||
image: 'node:18-bullseye-slim',
|
||||
image: 'freeleaps/ci-essentials:0.0.1',
|
||||
ttyEnabled: true,
|
||||
command: 'sleep',
|
||||
args: 'infinity'
|
||||
@ -600,7 +600,7 @@ spec:
|
||||
containers: [
|
||||
containerTemplate(
|
||||
name: "argo-app-version-updater",
|
||||
image: "debian:12",
|
||||
image: "freeleaps/ci-essentials:0.0.1",
|
||||
ttyEnabled: true,
|
||||
command: 'sleep',
|
||||
args: 'infinity'
|
||||
@ -673,7 +673,7 @@ spec:
|
||||
effect: "NoSchedule"
|
||||
containers:
|
||||
- name: commit-message-linter
|
||||
image: docker.io/commitlint/commitlint:master
|
||||
image: docker.io/freeleaps/ci-essentials:0.0.1
|
||||
command:
|
||||
- cat
|
||||
tty: true
|
||||
|
||||
65
infra/ci-essentials/Dockerfile
Normal file
65
infra/ci-essentials/Dockerfile
Normal file
@ -0,0 +1,65 @@
|
||||
FROM debian:bookworm
|
||||
|
||||
LABEL version="0.0.1"
|
||||
LABEL description="Packed with essential tools for Freeleaps DevOps System"
|
||||
LABEL maintainer="Freeleaps <https://freeleaps.com>"
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
SHELL ["/bin/bash", "-l", "-euxo", "pipefail", "-c"]
|
||||
|
||||
USER root
|
||||
|
||||
# Install essential tools
|
||||
RUN apt-get update; \
|
||||
apt-get full-upgrade -y; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
git \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
vim \
|
||||
nano \
|
||||
jq \
|
||||
dnsutils \
|
||||
net-tools \
|
||||
iputils-ping \
|
||||
iproute2 \
|
||||
telnet \
|
||||
openssh-client \
|
||||
bash \
|
||||
ca-certificates \
|
||||
; \
|
||||
apt-get clean; \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
ENV NVM_DIR=/usr/local/nvm
|
||||
|
||||
# Install nvm to management node versions
|
||||
RUN mkdir -p "$NVM_DIR"; \
|
||||
curl -o- \
|
||||
"https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh" | \
|
||||
bash \
|
||||
; \
|
||||
source $NVM_DIR/nvm.sh; \
|
||||
nvm install --lts --latest-npm
|
||||
|
||||
# Add node and npm to path so the commands are available
|
||||
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION/lib/node_modules
|
||||
ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
|
||||
|
||||
# Install semantic release and conventional commits cli
|
||||
RUN npm install -g \
|
||||
semantic-release \
|
||||
@semantic-release/changelog \
|
||||
@semantic-release/git \
|
||||
@semantic-release/exec \
|
||||
@semantic-release/release-notes-generator \
|
||||
conventional-changelog-conventionalcommits \
|
||||
@commitlint/cli \
|
||||
@commitlint/config-conventional \
|
||||
@commitlint/config-angular
|
||||
|
||||
RUN mkdir -p /workspace
|
||||
WORKDIR /workspace
|
||||
USER root
|
||||
Loading…
Reference in New Issue
Block a user