Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The While Action action will continue to execute its children until a certain condition is met. The condition is specified in the While action and uses the same condition syntax as Agent Requirements, Stage Gates and Configuration Conditions.

...

This example demonstrates a way to use the while action to repeat the same tasks. All it does is loops 10 times and each time it loops it executes the Delay Actionaction. First you need to declare a variable which has the starting value of the loop and also doubles as the counter variable which increments in value each pass of the loop. To do this, create a Configuration Variable called "Counter" and set the Type to Numeric and Value to 0.

...

Now head back to the Stage Editor and click the While Actionaction. You'll need to select Less Than from the Operator drop down list to get the Right Value input field to appear. The Right Value is straight forward, put in the number 10 or whatever number you would like to count up to. The Left Value will need to reference the Counter Configuration variable we create in the last step.

...

It's important to note, as explained on the Variables, Objects & Expressions page the way the Counter variable is referenced here in this action. Even though it's a Configuration variable, I have chosen to remove the Configuration namespace prefix and reference it using only its name. The next step is to increment the Counter variable using the Set Variable Actionaction. Select the Counter variable from the list and make sure you change the Operation type to Append or increment. Then set the New Value to the amount you want the counter incremented by, in this case we'll use 1.

Note: The Configuration Variable Counter which we change the value of in the Set Variable Action action is not actually modified, the value of it is copied into the Build namespace and modified there. To reference the new value in the Build namespace we use the syntax %Counter%. That is why we excluded the Configuration namespace prefix when specifying the Counter variable in the While Actionaction. We want the While Action action to use the updated value in the Build namespace. If we were to use %Configuration.Counter% then the value would always be what we set it to on the Variables page which was 0.

...

Once you've setup the While Action action and the Set Variable Actionaction, you can begin putting actions in the while loop you want executed each pass. For simplicity I'll add the Delay Actionaction. Your final workflow should look like this.

...