It's all about the answers!

Ask a question

Multiple IF Statements in the same step


Jeremy Bucchi (1121) | asked Jun 21 '10, 10:01 a.m.
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



permanent link
Brent Ulbricht (2.5k11) | answered Jun 21 '10, 11:46 a.m.
JAZZ DEVELOPER
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!


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

permanent link
Jeremy Bucchi (1121) | answered Jun 25 '10, 10:29 a.m.
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!


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.

permanent link
Jirong Hu (1.5k9295258) | answered Dec 14 '13, 3:32 p.m.
 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


Register or to post 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.