Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48565

Pipeline: When Jenkins build fails the execution is restarted after every SCM poll

XMLWordPrintable

      I have a pipeline configured below.

       

      When the build fails it will execute every time SCM check runs. Despite that fact that retry is disabled. This is generating a lot of log files, and unnecessary resource usage.

      @Library('jenkins-library')_
      def buildInfoMap
      def buildVersion='NoVersion'
      
      pipeline {
          //node('build-rh5-01') would fix 1 specific node - use labels instead
          agent { label 'rhel5' }
          options {
              // Make sure Pipeline doesn't run over 30 minutes
              timeout(time: 30, unit: 'MINUTES')
              // Make sure only 1 instance can run at 1 time
              disableConcurrentBuilds()
              // Retry only once if something has gone wrong
              //retry(1)
          }
      
          stages {
              stage('\u2776 Pre-commit') {
                  steps {
                      echo "Need to work out Pre-Commit section"
                  }
              }
      
              stage('\u2777 Module Test') {
                  steps {
                      script {
                          String view = """//service-platform/sp-uav/Dev/... //jenkins-${NODE_NAME}-${JOB_NAME}/...""".stripMargin()
      
                          new com.mycompany.abc.jenkins.P4Scm(this).p4Checkout("p4-open", view)
                          buildVersion = new com.mycompany.abc.jenkins.Utils(this).extractMvnBuildVersion('pom.xml')
      
                          withMaven(jdk: 'JDK8', maven: 'Maven3', mavenSettingsConfig: 'global-maven-config') {
                              withSonarQubeEnv('QMS') {
                                  sh 'mvn clean install -Pbuild-rpm -P docker'
                              }
                          }
                      }
                  }
      
                  post {
                      always {
                          script {
                              step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, consoleParsers: [[parserName: 'Maven'], [parserName: 'Java Compiler (javac)']], defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', unHealthy: ''])
                          }
                      }
      
                      success {
                          junit 'useractivityvault-app/target/surefire-reports/TEST-*.xml'
                          script {
                              archiveArtifacts artifacts: '**/*.rpm', excludes: '**/*.jar, **/*.pom, **/*.war', fingerprint: true
                          }
                      }
                  }
              }
      
              stage('\u2777 Sonar Execution') {
                  steps{
                      script{
                          withMaven(jdk: 'JDK8', maven: 'Maven3', mavenSettingsConfig: 'maven-settings') {
                              withSonarQubeEnv('QMS') {
                                  sh 'mvn sonar:sonar'
                              }
                          }
                      }
                  }
              }
      
              stage('\u2778 Artifactory Upload') {
                  steps {
                      script {
                          // Make sure there is a trailing slash at the end of the string
                          buildInfoMap = new com.mycompany.abc.jenkins.ArtifactoryUpload(this).upload("${artifactory_repo_RF_MIT}/${env.JOB_BASE_NAME}/${buildVersion}/")
                      }
                  }
              }
      
              stage('\u2779 Module Integration Test') {
                  agent { label 'module-test-env-ready' }
                  steps {
                      script {
                          // Configure artifactory yum repo
                          sh """
                              cat <<EOF > /tmp/artifactory.repo
                              [artifactory]
                              name=Artifactory
                              baseurl=https://artifactory-pro:password!@artifactory-pro.hq.k.grp/list/opf-rpm-c-mit-local/
                              failovermethod=priority
                              enabled=1
                              gpgcheck=0
                              sslverify=0
                              EOF
                              sudo cp /tmp/artifactory.repo /etc/yum.repos.d
                          """
      
                          // Install required rpm's
                          sh """
                              echo "Installing test suite..."
                              sudo yum -y install useractivityvault-test-suite.noarch
                          """
      
                          // Run module integration tests
                          sh """
                              /opt/test-suites/useractivityvault/test -Djersey.test.host=cdlab1-srv02 -Djersey.test.port=5755 -Dcassandra.seeds=cdlab1-srv02
                          """
                      }
                  }
              }
      
              stage('\u277A Artifactory Promotion') {
                  steps {
                      script {
                          sh "echo 'TBD'"
                          //new com.mycompany.abc.ArtifactoryUpload(this).promote(info.buildInfo,info.sourceRepo,"generic-local-release/srm-legacy-snapshot-repo",true)
                      }
                  }
              }
          }
      
          post {
              always {
                  script{
                      new com.mycompany.abc.jenkins.ChatOps(this).sendNotification('team-uk3')
                  }
              }
          }
      }

            Unassigned Unassigned
            pteichner Peter Teichner
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: