diff --git a/ci/Jenkinsfile.titan-iac b/ci/Jenkinsfile.titan-iac index 359dc94..77990d7 100644 --- a/ci/Jenkinsfile.titan-iac +++ b/ci/Jenkinsfile.titan-iac @@ -22,7 +22,6 @@ spec: environment { PIP_DISABLE_PIP_VERSION_CHECK = '1' PYTHONUNBUFFERED = '1' - DEPLOY_BRANCH = 'deploy' } stages { stage('Checkout') { @@ -40,7 +39,27 @@ spec: sh 'pytest -q ci/tests/glue' } } + stage('Resolve Flux branch') { + steps { + script { + env.FLUX_BRANCH = sh( + returnStdout: true, + script: "awk '/branch:/{print $2; exit}' clusters/atlas/flux-system/gotk-sync.yaml" + ).trim() + if (!env.FLUX_BRANCH) { + error('Flux branch not found in gotk-sync.yaml') + } + echo "Flux branch: ${env.FLUX_BRANCH}" + } + } + } stage('Promote') { + when { + expression { + def branch = env.BRANCH_NAME ?: (env.GIT_BRANCH ?: '').replaceFirst('origin/', '') + return env.FLUX_BRANCH && branch == env.FLUX_BRANCH + } + } steps { withCredentials([usernamePassword(credentialsId: 'gitea-pat', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_TOKEN')]) { sh ''' @@ -48,7 +67,7 @@ spec: git config user.email "jenkins@bstein.dev" git config user.name "jenkins" git remote set-url origin https://${GIT_USER}:${GIT_TOKEN}@scm.bstein.dev/bstein/titan-iac.git - git push origin HEAD:${DEPLOY_BRANCH} + git push origin HEAD:${FLUX_BRANCH} ''' } } diff --git a/services/jenkins/configmap-jcasc.yaml b/services/jenkins/configmap-jcasc.yaml index fcd01f9..62012f1 100644 --- a/services/jenkins/configmap-jcasc.yaml +++ b/services/jenkins/configmap-jcasc.yaml @@ -139,24 +139,33 @@ data: } } } - pipelineJob('titan-iac-quality-gate') { - triggers { - scm('H/5 * * * *') - } - definition { - cpsScm { - scm { + multibranchPipelineJob('titan-iac-quality-gate') { + branchSources { + branchSource { + source { git { - remote { - url('https://scm.bstein.dev/bstein/titan-iac.git') - credentials('gitea-pat') - } - branches('*/feature/ariadne') + id('titan-iac-quality-gate') + remote('https://scm.bstein.dev/bstein/titan-iac.git') + credentialsId('gitea-pat') } } + } + } + factory { + workflowBranchProjectFactory { scriptPath('ci/Jenkinsfile.titan-iac') } } + orphanedItemStrategy { + discardOldItems { + numToKeep(30) + } + } + triggers { + periodicFolderTrigger { + interval('12h') + } + } } base.yaml: | jenkins: diff --git a/services/jenkins/configmap-plugins.yaml b/services/jenkins/configmap-plugins.yaml index eabea13..108c646 100644 --- a/services/jenkins/configmap-plugins.yaml +++ b/services/jenkins/configmap-plugins.yaml @@ -9,6 +9,7 @@ data: kubernetes workflow-aggregator git + git-branch-source pipeline-utility-steps configuration-as-code configuration-as-code-support diff --git a/services/maintenance/kustomization.yaml b/services/maintenance/kustomization.yaml index 0810f5e..b7fe46b 100644 --- a/services/maintenance/kustomization.yaml +++ b/services/maintenance/kustomization.yaml @@ -26,7 +26,7 @@ resources: images: - name: registry.bstein.dev/bstein/ariadne - newTag: 0.1.0-4 # {"$imagepolicy": "maintenance:ariadne"} + newTag: 0.1.0-5 # {"$imagepolicy": "maintenance:ariadne"} configMapGenerator: - name: disable-k3s-traefik-script