If return is called from the "top level" of a script (ie not inside a 
function) then it should return early. 

eg: 

node {

  echo "42"
  if (42 == 42) {
      currentBuild.result = 'UNSTABLE'
      return
  }
   echo "43"
}

This will exit early and never print "43". 

On Wednesday, June 29, 2016 at 2:28:37 PM UTC+10, Lionel Orellana wrote:
>
> From what I've tried simply returning doesn't stop the execution of the 
> script. 
>
> If you throw an exception the result seems to always be FAILURE. 
>
> I would like to know if there is a way to stop execution but leave the 
> result as say UNSTABLE.
>
> On Monday, 30 May 2016 18:38:41 UTC+10, Michael Neale wrote:
>>
>> you can just return - and it should exit the script? (or throw an 
>> exception).
>>
>> On Monday, May 30, 2016 at 5:21:16 PM UTC+10, Feng Yu wrote:
>>>
>>> Hi there:
>>>     Here is my pipeline code:
>>> node{
>>>     // my code here
>>>     try {
>>>         // some steps
>>>         currentBuild.result = 'SUCCESS'
>>>     } catch (Exception err) {
>>>         currentBuild.result = 'FAILURE'
>>>         mail  // email to me if failed
>>>         // some clean steps
>>>     }
>>>
>>>     if (currentBuild.result == 'FAILURE') {
>>>         // How to exit pipeline ?
>>>     }
>>>
>>>     /*
>>>      * other steps here
>>>      */
>>> }
>>>
>>>
>>> How do I break the pipeline manually if some steps failed?
>>>
>>> Thanks.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/9cc4c0f6-deb8-4c14-b753-e3cc8c4e328e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to