Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Button handy
blanktrue
color#0052CC
nameSend Feedback
linkhttps://docs.google.com/forms/d/e/1FAIpQLScmToBe3vynAlb5fdKwCGxYqnTbDc66sIBgeecG2BuFDuHc7g/viewform?entry.2002826954=Running+Scripts+Via+REST+-+15482012
widthauto

In certain cases, it is necessary to run SIL Scripts from an outside source. 

...

  1. Create the script with hard-coded values and make sure it works the way you want it to.

  2. Replace the hard-coded values with variables that accept arguments (the argv variable) when run from an outside source.

  3. (optional) Test the script using the call() routinefunction. This is an important step to test the script without the complications of a network.

  4. Make modifications to the example curl script to test running the script.

I will break down each step with an example script that uses the createIssue() routinefunction.

Create a Script with Hard-Coded Values

...

Code Block
string project = argv[0];
string parent = argv[1];
string issueType = argv[2];
string summary = argv[3];
 
string newIssueKey = createIssue(
    project, 
    parent, 
    issueType, 
    summary
);
 
if (isNotNull(newIssueKey)){
    printInFile("debug.txt", "Issue " + newIssueKey + " was created.");
} else {
    printInFile("debug.txt", "An issue was not created");
}

Test the Script Using the Call()

...

Function

In a separate script, run the script using the call() routinefunction. Notice how the number of elements in the array matches the arguments used by argv in the above script. The arguments used should match all elements accessed in the script being called. 

...