Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Set value from "Build > Shell/Batch Command" step #4299

retzero ·

Hello.

I'm looking for the way to set build variable from Build > Shell/Batch Command step.
Below script failed to set variable.
Could you please guide me how to use this from Build > Shell/Batch Command step.

echo  ${vars.get("TEST_VAR")}

result_lines=$(bash ./test_echo_multiple_lines.sh)

echo "===="
echo "$result_lines" # <== OK.
echo "===="

${vars.get("TEST_VAR").setValue("$result_lines")} # <== FAIL. Updated to the raw string "$result_lines" not the actual texts.
${vars.get("TEST_VAR").setValue("${result_lines}")} # <== FAIL. mvel
  • solved #2
  • replies 1
  • views 891
  • stars 1
robinshen ADMIN ·

This is not possible. All embedded scripts will be evaluated before your command is executed. To capture outout of a command, please change your step type to "Misc/Execute Script", and define the script as:

groovy:
def output = util.readOutput("bash " + configuration.workspaceDir.absolutePath + "/test_echo_multiple_lines.sh");
vars.get("TEST_VAR").setValue(output);