Multiple IF Statements in the same step
Is there a way to do multiple if statements in a step?
I want to make a decision on what selector to use given the value of a certain environment variable. For example: If $MYVAR == "value1" THEN choose selector A If $MYVAR == "value2" THEN choose selector B etc. Is there an easy way to accomplish this? Thanks! |
3 answers
Is there a way to do multiple if statements in a step? Hi Jeremy, There are a couple of options that may work for you. If you're using a 7.1.x release, the Conditional step is something to consider. In the UI if you choose to make the 'Step Type' Conditional, the page will open up a field for a condition. In the condition you could add something like 'true($MYVAR eq value1)', which will run the command text and inline if true. If false, it will run an else command and else inline. I'm assuming you're thinking of using the .bset dot command with the selector option to change the selector. Another option that is a possibility is to use the .run or .runwait command with the -c option that would call another project to change the selector. Your step type would just be regular, and in the text of the command you would have something like the following: .runwait -c "$MYVAR=value1" "Value_1_Project" .runwait -c "$MYVAR=value2" "Value_2_Project" bju |
Is there a way to do multiple if statements in a step? Hi Jeremy, There are a couple of options that may work for you. If you're using a 7.1.x release, the Conditional step is something to consider. In the UI if you choose to make the 'Step Type' Conditional, the page will open up a field for a condition. In the condition you could add something like 'true($MYVAR eq value1)', which will run the command text and inline if true. If false, it will run an else command and else inline. I'm assuming you're thinking of using the .bset dot command with the selector option to change the selector. Another option that is a possibility is to use the .run or .runwait command with the -c option that would call another project to change the selector. Your step type would just be regular, and in the text of the command you would have something like the following: .runwait -c "$MYVAR=value1" "Value_1_Project" .runwait -c "$MYVAR=value2" "Value_2_Project" bju Thanks for the reply bju. I like the idea of using the conditional block, but I can only use one condition in that case. I take it I could use multiple conditional steps to eventually get the result I'm looking for, but performance would then be a problem (it would take much to long to run an additional 4+ steps). What I really need is some type of Build Forge case or switch statement. Because that is not available, I'm trying to do it through an IF statement. Thanks again for you help. |
What's the best way to achieve the following:
if (ENV == "DEV")
copy to DEV server
if (ENV == "TST")
copy to TST server
if (ENV == "PRD")
copy to PRD server
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.