Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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!

0 votes



3 answers

Permanent link
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

0 votes


Permanent link
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.

0 votes


Permanent link
 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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Jun 21 '10, 10:01 a.m.

Question was seen: 8,853 times

Last updated: Dec 14 '13, 3:32 p.m.

Confirmation Cancel Confirm