[JIRA] (JENKINS-62028) Jenkins pipeline fails to properly abort loop

15 views
Skip to first unread message

cw-jenkins-io@rizzistrasse.at (JIRA)

unread,
Apr 23, 2020, 5:10:03 AM4/23/20
to jenkinsc...@googlegroups.com
Christian Werner created an issue
 
Jenkins / Bug JENKINS-62028
Jenkins pipeline fails to properly abort loop
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline
Created: 2020-04-23 09:09
Priority: Major Major
Reporter: Christian Werner
  1. Linux - Debian
  2. Jenkins 2.204.2
  3. Create pipeline:
    pipeline {
       agent any   stages {
          stage('Ping') {
             steps {
                 script {
                   for (def i = 0; i < 500; i++) {
                      echo "currentResult: ${currentBuild.currentResult}"
                      sh "ping 127.0.0.1 -c 1"
                    }
               }              
             }
          }
       }
    }
    
  4. run pipeline
  5. Abort pipeline
  6. View build log
    Expected: pipeline aborts
    Actual:
  7. The pipeline gets resumed, without interruption
  1. updated code to see the expected behauvior
    pipeline {
       agent any
    
       stages {
          stage('Ping') {
             steps {
                 script {
                   for (def i = 0; i < 500; i++) {
                      
                      if (currentBuild.rawBuild.getActions(jenkins.model.InterruptedBuildAction.class).isEmpty()) {
                        echo "currentResult: ${currentBuild.currentResult}"
                    } else {
                        echo "ABORTED"
                        error("aborted")
                    }
                      sh "ping 127.0.0.1 -c 1"
                      
                    }
               }  
                
             }
          }
       }
    }
    
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

cw-jenkins-io@rizzistrasse.at (JIRA)

unread,
Apr 23, 2020, 5:11:02 AM4/23/20
to jenkinsc...@googlegroups.com
Christian Werner updated an issue
Change By: Christian Werner
# Linux - Debian
# Jenkins 2.204.2
# Create pipeline:
{code:java}
pipeline {
   agent any


   stages {
      stage('Ping') {
         steps {
             script {
               for (def i = 0; i < 500; i++) {
                  echo "currentResult: ${currentBuild.currentResult}"
                  sh "ping 127.0.0.1 -c 1"
                }
           }              
         }
      }
   }
}
{code}
# run pipeline
# Abort pipeline
# View build log
Expected: pipeline aborts
Actual:
# The pipeline gets resumed, without interruption



#  updated code to see the expected behauvior
{code}

pipeline {
   agent any

   stages {
      stage('Ping') {
         steps {
             script {
               for (def i = 0; i < 500; i++) {
                  
                  if (currentBuild.rawBuild.getActions(jenkins.model.InterruptedBuildAction.class).isEmpty()) {
                    echo "currentResult: ${currentBuild.currentResult}"
                } else {
                    echo "ABORTED"
                    error("aborted")
                }
                  sh "ping 127.0.0.1 -c 1"
                  
                }
           }  
            
         }
      }
   }
}
{code}

cw-jenkins-io@rizzistrasse.at (JIRA)

unread,
Apr 26, 2020, 1:29:02 AM4/26/20
to jenkinsc...@googlegroups.com

dbeck@cloudbees.com (JIRA)

unread,
Apr 30, 2020, 4:36:02 AM4/30/20
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages