gitreef

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 6fc58724f27a225f8561222730609cd8352d3a47
parent 46c5aee60c0c1d25b7e8577a2d466875186f77d4
Author: Matthias Jaros <jaros@mailbox.org>
Date:   Mon, 20 Oct 2025 08:34:00 +0200

Created Jenkinsfile

Diffstat:
A.gitignore | 2++
AJenkinsfile | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +/ssh +/repos diff --git a/Jenkinsfile b/Jenkinsfile @@ -0,0 +1,72 @@ +pipeline { + agent { + label 'docker' + } + triggers { + pollSCM('H/5 * * * *') // every ~5 minutes + } + + // 👇 Fill these for your setup + environment { + GIT_URL = '/var/git/git-server' + GIT_BRANCH = 'trunk' + GIT_CREDENTIALS = '' // Jenkins credentialsId (leave empty for public) + REGISTRY = 'docker.it-jaros.com' // e.g. ghcr.io/you or registry.example.com/namespace + PLATFORMS = 'linux/arm64/v8,linux/amd64' + } + + stages { + stage('Checkout') { + steps { + script { + if (env.GIT_CREDENTIALS?.trim()) { + checkout([$class: 'GitSCM', + branches: [[name: "*/${GIT_BRANCH}"]], + userRemoteConfigs: [[url: GIT_URL, credentialsId: GIT_CREDENTIALS]], + ]) + } else { + git branch: GIT_BRANCH, url: GIT_URL + } + } + } + } + + stage('Extract vars') { + steps { + script { + env.GIT_SHA = sh(script: "git rev-parse --short HEAD", returnStdout: true).trim() + + // compose image name + tags + env.GROUP_ID = "com.it-jaros.git" + env.IMAGE_NAME = "${REGISTRY}/${GROUP_ID}" + echo "sha=${env.GIT_SHA}" + echo "image=${env.IMAGE_NAME}" + } + } + } + + stage('Docker buildx (multi-arch)') { + steps { + withCredentials([usernamePassword( + credentialsId: 'docker', + usernameVariable: 'DOCKER_USER', + passwordVariable: 'DOCKER_PASS' + )]) { + sh ''' + docker version + docker buildx version + docker buildx ls | grep -q multiarch || docker buildx create --name multiarch --use --bootstrap + echo "$DOCKER_PASS" | docker login $REGISTRY -u "$DOCKER_USER" --password-stdin + + DOCKER_BUILDKIT=1 docker buildx build \ + --platform ${PLATFORMS} \ + -t ${IMAGE_NAME}:${GIT_SHA} \ + -t ${IMAGE_NAME}:latest \ + --push \ + . + ''' + } + } + } + } +}