Hello, I am writing to inquire about the possibility of implementing a "skipped" processing method within a script in the step. Specifically, I am working on a script that searches for devices based on certain conditions, and I would like to implement the following logic:
If a matching device is found, the step should pass.
If no matching device is found, the step should be marked as skipped.
If the script fails, the step should be marked as failed.
Could you please provide guidance on about this script processing?
As long as the step runs, it is no longer possible to mark it as skipped. You may set some other flag (variable for instance) to convey the "no matching device" info though.
The best way to do this is to set Execute Condtion on the step you wish to have skipped.
First set the Execute Condition to: "If all specified criterias are satisfied".
Second add 2 criteria to be specified (ideally in this order):
- If all previous sibling steps are successful
- If specified variable evaluates to true (and select your QuickBuild variable with the value if it should skip)
If you do not have a variable for your skip, then you can make the second criteria be "If specified script evaluates to true", and use this code snippet for your purposes, replacing the variable with some script condition. In this example it is functionally identical to using criteria "If specified variable evaluates to true".
groovy:
if( vars.get("SomeVariable").asBoolean() )
{
return true;
}
return false;
If you just put the script condition on the execution criteria you can have your step execute if previous steps had failed or other unexpected build statuses.