From 32e300b862c01d9834119ebc164040073608495f Mon Sep 17 00:00:00 2001 From: Arne Teuke Date: Thu, 22 May 2025 18:58:29 +0200 Subject: [PATCH] fix build info and Jenkins pipeline --- Jenkinsfile | 46 ++++++++++++++++++++++++++++------------------ README.md | 4 ++-- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 199be3d..47679c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,10 +25,16 @@ pipeline { stage('pull master') { steps { sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) { - sh '''git config user.name "Jenkins Server" - git config user.email jenkins@confdroid.com - git pull origin master - git checkout -b jenkins ''' + sh ''' + git config user.name "Jenkins Server" + git config user.email jenkins@confdroid.com + # Ensure we're on the development branch (triggered by push) + git checkout development + # Create jenkins branch from development + git checkout -b jenkins-build-$BUILD_NUMBER + # Optionally merge master into jenkins to ensure compatibility + git merge origin/master --no-ff || { echo "Merge conflict detected"; exit 1; } + ''' } } } @@ -53,23 +59,25 @@ pipeline { steps { sh '''/usr/local/bin/puppet-lint . \\ --no-variable_scope-check \\ + || { echo "Puppet lint failed"; exit 1; } ''' } } stage('SonarScan') { steps { - sh ''' - /opt/sonar-scanner/bin/sonar-scanner \ - -Dsonar.projectKey=resources_cd \ - -Dsonar.sources=. \ - -Dsonar.host.url=https://sonarqube.confdroid.com \ - -Dsonar.token=sqa_aca21cc41336d0f31987ed196ccfb9be55ded774 - ''' - } + withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) { + sh ''' + /opt/sonar-scanner/bin/sonar-scanner \ + -Dsonar.projectKey=resources_cd \ + -Dsonar.sources=. \ + -Dsonar.host.url=https://sonarqube.confdroid.com \ + -Dsonar.token=$SONAR_TOKEN + ''' + } + } } - stage('create Puppet documentation') { steps { sh '/opt/puppetlabs/bin/puppet strings' @@ -79,12 +87,14 @@ pipeline { stage('update repo') { steps { sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) { - sh '''git config user.name "Jenkins Server" - git config user.email jenkins@confdroid.com - echo `git add -A && git commit -am "recommit for updates in build $BUILD_NUMBER"` - git push origin HEAD:master''' + sh ''' + git config user.name "Jenkins Server" + git config user.email jenkins@confdroid.com + git add -A && git commit -am "Recommit for updates in build $BUILD_NUMBER" || echo "No changes to commit" + git push origin HEAD:master + ''' } } } } -} +} \ No newline at end of file diff --git a/README.md b/README.md index 4aec106..78e8b71 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Readme -[![Build Status](https://pipelines.confdroid.com/buildStatus/icon?job=resourced_cd)](https://pipelines.confdroid.com/job/resources_cd/) +[![Build Status](https://jenkins.confdroid.com/buildStatus/icon?job=resourced_cd)](https://jenkins.confdroid.com/job/resources_cd/) [[_TOC_]] @@ -35,7 +35,7 @@ via site.pp or nodes.pp ```bash node 'example.example.net' { - include cd_kubernetes + include resources_cd } ```