It's all about the answers!

Ask a question

Can you have an && condition with Buildforge Conditional steps?


Daniel martin (10122926) | asked Jun 18 '14, 2:26 p.m.
 In need to ensure that two variables have values before executing a command.  I can test if either of them have content, but when i attempt: (${GROUP_NAME} !="" && $BD=True) the valuation is always False.  If it is possible what am I doing wrong?

4 answers



permanent link
Ryan Ruscett (1.0k413) | answered Jun 19 '14, 8:20 a.m.
 Oh Yes, I forgot to mention. I was talking to someone about this and the workaround would be to create two steps. Evaluate one condition. Then the next step evaluates the second condition and the third step would evaluate the results of step 1 and step 2. This would be an easy way to go about it. This way you could use libraries to call functionality of what to do in what type of situation. I think this is probably the best way to do it.

Thanks!

permanent link
Ryan Ruscett (1.0k413) | answered Jun 19 '14, 8:16 a.m.
You are welcome to open an RFE against this type of functionality, but the condition portion of the step only supports a single condition. It's not that it's a defect but more an enhancement to have the condition handle multiple evaluations. 

You can open an RFE here. Here you can track the RFE and make comments and allow others to like your request etc. 

https://www.ibm.com/developerworks/rfe/execute?use_case=changeRequestLanding



permanent link
Ryan Ruscett (1.0k413) | answered Jun 18 '14, 5:26 p.m.
Hello,

I see your issue. When using a single evaluation for the condition it chooses between the command and else command properly. Whenever using && it always evaluates to false and instead of the else it skips the step just like what you are running into now. 

After taking a deeper look it appears it takes True=True and compares it to com.hsbc.ds != ' ' as strings which will never be the same. So it always evaluates to false in which it should run the else command. In all my testing it always did run the else command when the values equaled false. 

What I would recommend. Is creating a small batch script that does an if statement to compare the two. Then it will either return 0 or 1. Then plugin that into a conditional step and say true(expression) and if true it runs the command if false it runs the else. I was able to get around doing this. 

I was playing with K shell and it was something like this.
if [[ $hello = hello && $name = "ryan" ]];then
	
return 0
	
fi
	
return 1
	

I hope that helps.
	

Thanks!
	
  
	



Comments
Daniel martin commented Jun 19 '14, 8:09 a.m.

Thanks Ryan, I will open a defect up against Build Forge.  


permanent link
Ryan Ruscett (1.0k413) | answered Jun 18 '14, 2:59 p.m.
 Hello,

The logic in your command may be a little off.

1. Group_Name NOT eq to "" 
    A. This means that the command after the && will only be executed if Group_Name is not equal to nothing. If it is            equal to "" then you are in trouble.
2. If Group_Name is not equal to nothing we move on to BD = true.
   
I assume that because you are doing a != "" means that at times it is? Well when it is the second part wont ever get executed. 

Does that help?


Comments
Daniel martin commented Jun 18 '14, 3:26 p.m.

  Hey Ryan,

Basically I am trying to validate that GROUP_NAME has text, not equal to "", and the BD equals True. If GROUP_NAME is empty then the step should go to the else command.  I have tried all the combinations i can, and nothing seems to work:  

COND The condition on the step [True=True &&com.hsbc.ds != ' '] evaluated false, step will not be executed.

I would have expected this to evaluate to true


Daniel martin commented Jun 18 '14, 4:48 p.m.

 Even when i force everything to be true it reports false:

COND    The condition on the step [(True=True) && (com.hsbc.ds=com.hsbc.ds)] evaluated false, step will not be executed.
    

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.