[JIRA] (JENKINS-38870) Allow conditions to be repeated

2 views
Skip to first unread message

stephenconnolly@java.net (JIRA)

unread,
Oct 10, 2016, 12:27:01 PM10/10/16
to jenkinsc...@googlegroups.com
stephenconnolly created an issue
 
Jenkins / Improvement JENKINS-38870
Allow conditions to be repeated
Issue Type: Improvement Improvement
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2016/Oct/10 4:26 PM
Priority: Minor Minor
Reporter: stephenconnolly

It can be confusing as to how to construct a sequence of commands to be executed during a condition, e.g.

pipeline {
  postBuild {
    success {
      sh 'echo Awesome > message'
      archive 'message'
      sh 'do something else'
    }
    failure {
      sh 'echo Disaster > message'
      archive 'message'
      sh 'rage something'
    }
  }
}

What happens if the success archive step fails? Will we "do something else" or will we stop at that point?

What happens if the failure archive step fails? Will we "rage something" or will we stop at the failure?

The principle of least surprise suggests that we should behave the same way for both.

We can argue that the steps in a condition block are actually wrapped steps around the actual steps and that they will be all executed providing the outer condition object holds... that is at least consistent amongst conditions... but it is not consistent with steps or the use of blocks elsewhere.

An alternative would be to allow the conditions to be repeated and define the sequence in which conditions are evaluated as being their order of definition, thus

pipeline {
  postBuild {
    success {
      sh 'echo Awesome > message'
    }
    success {
      archive 'message'
    }
    success {
      sh 'do something else'
    }
    failure {
      sh 'echo Disaster > message'
    }
    failure {
      archive 'message'
      sh 'rage something'
    }
  }
}

which clarifies the intent that the three success conditions will only be executed in the event of success being maintained and that the "rage something" will only occur during a failure if the archive step is successful.

It also would enable other sequences to be expressed, e.g.:

pipeline {
  postBuild {
    success {
      sh 'echo Awesome > message'
    }
    failure {
      sh 'echo Disaster > message'
    }
    always {
      archive 'message'
    }
    success {
      sh 'do something else'
    }
    failure {
      sh 'rage something'
    }
  }
}
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

stephenconnolly@java.net (JIRA)

unread,
Oct 10, 2016, 12:28:01 PM10/10/16
to jenkinsc...@googlegroups.com
stephenconnolly updated an issue
Change By: stephenconnolly
It can be confusing as to how to construct a sequence of commands to be executed during a condition, e.g.

{code}

pipeline {
  postBuild {
    success {
      sh 'echo Awesome > message'
      archive 'message'
      sh 'do something else'
    }
    failure {
      sh 'echo Disaster > message'
      archive 'message'
      sh 'rage something'
    }
  }
}
{code}


What happens if the success {{archive}} step fails? Will we "do something else" or will we stop at that point?

What happens if the failure {{archive}} step fails? Will we "rage something" or will we stop at the failure?

The principle of least surprise suggests that we should behave the same way for both.

We can argue that the steps in a condition block are actually wrapped steps around the actual steps and that they will be all executed providing the outer condition object holds... that is at least consistent *amongst conditions*... but it is not consistent with steps stages or the use of blocks elsewhere.


An alternative would be to allow the conditions to be repeated and define the sequence in which conditions are evaluated as being their order of definition, thus

{code}

pipeline {
  postBuild {
    success {
      sh 'echo Awesome > message'
    }
    success {
      archive 'message'
    }
    success {
      sh 'do something else'
    }
    failure {
      sh 'echo Disaster > message'
    }
    failure {
      archive 'message'
      sh 'rage something'
    }
  }
}
{code}  


which clarifies the intent that the three success conditions will only be executed in the event of success being maintained and that the "rage something" will only occur during a failure if the archive step is successful.

It also would enable other sequences to be expressed, e.g.:

{code}

pipeline {
  postBuild {
    success {
      sh 'echo Awesome > message'
    }
    failure {
      sh 'echo Disaster > message'
    }
    always {
      archive 'message'
    }
    success {
      sh 'do something else'
    }
    failure {
      sh 'rage something'
    }
  }
}
{code}  

andrew.bayer@gmail.com (JIRA)

unread,
Feb 27, 2017, 4:37:04 PM2/27/17
to jenkinsc...@googlegroups.com
Andrew Bayer resolved as Won't Fix
Change By: Andrew Bayer
Status: Open Resolved
Resolution: Won't Fix

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:24:58 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Won't Fix
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages