From b757370c1d1ce3c5e5e0cf874b6b55b3b05cecda Mon Sep 17 00:00:00 2001 From: Arne Teuke Date: Mon, 19 May 2025 22:44:49 +0200 Subject: [PATCH] add new pipeline settings --- Jenkinsfile | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 533e10a..76701db 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,13 +22,19 @@ pipeline { stages { - stage('pulling master') { + 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; } + ''' } } } @@ -51,21 +57,25 @@ pipeline { stage('puppet-lint') { steps { - sh '''/usr/local/bin/puppet-lint . + 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=cd_apache \ - -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=cd_apache \ + -Dsonar.sources=. \ + -Dsonar.host.url=https://sonarqube.confdroid.com \ + -Dsonar.token=$SONAR_TOKEN + ''' + } + } } stage('create Puppet documentation') { @@ -77,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