Release Automation

 View Only
  • 1.  Javascript Action test failed

    Posted Aug 09, 2017 12:55 PM

    Any tutorial and example to write javascript code for an action?  I got the following error when I tried to test the javascript I just wrote.  So the input2 and input3 have to be updated in javascript execution? This does not make sense. I just want to get the value from input and use it in the javascript code.  There is no need I have to update it after I use it.

  • 2.  Re: Javascript Action test failed

    Broadcom Employee
    Posted Aug 09, 2017 02:39 PM

    Unfortunately, we don't have any JavaScript samples that I'm aware of from a Support standpoint. guewa01, do you know if your team has anything of the sort handy?

  • 3.  Re: Javascript Action test failed
    Best Answer

    Posted Aug 10, 2017 01:49 AM

    the error you're facing has nothing to do with the javascript code. the problem is, that you can't simply test the action with parameters as inputs, when the parameters don't have a value yet. you will get the same error with any other action.


    also, the javascript action doesn't even know the parameter names, as it internally only references "input1, input2" etc.

  • 4.  Re: Javascript Action test failed

    Broadcom Employee
    Posted Aug 10, 2017 10:30 AM



    Michael is absolutely correct. It appears that you never gave the two parameters that it is complaining about a value and an action cannot run if a parameter it is using has not be given a value. As for examples of using the Javascript action, you can look at these two:

    Split Strings Into Array With Execute JavaScript regex 

    collection element associated with artifact type empty 


    Kind regards,

  • 5.  Re: Javascript Action test failed

    Posted Aug 10, 2017 02:19 PM

    I usually test JavaScript outside CA-RA, then copy it back in once working (e.g. JavaScript Tester online).  To make this easier, I will start my script by assigning the input values to variables that are then used in the script.  For example, if I know that input1 and input2 will be used in my script, rather than use then directly in the logic, I will code this at the top:


    var myvar1 = input1;

    var myvar2 = input2;

    (Obviously I use more meaningful names than myvar1 and myvar2)


    Then I reference myvar1 and myvar2 in my code.  What this means is that in the JS testing tool, I can declare and provide values to input1 and input2, but I leave those lines behind when I copy into CA-RA (or I may bring them over as comments to make continuned testing easier).  


    Doing this, I can validate my JS code is doing what it is supposed to without the need to have everything in CA-RA initialized.  


    Hope this helps...