Tcl script started from jenkins turns the command to lowercase

Viewed 330

I'm having a strange issue when running a tcl command in jenkins.

The tcl script has the following lines (pay attention to the uppercase I in Id):

foreach name $docker_names {
  set name "TestName"
  puts $name
  set command "docker inspect --format='{{.Id}}' ${name} > /home/temp/id.txt"
  send -- "$command\n"
  expect "$"
}

In the jeknins log I see that the job fails because what is sent in the second iteration of the loop is the command above but in lowercase. I need the I in Id to be uppercase.

This is what is sent in the second iteration of the loop:

docker inspect --format='{{.id}}' testname > /home/temp/id.txt

NOTE: In the first iteration, everything is sent correctly.

Anyone has an idea of why this is happening?

Thanks!

1 Answers

It can't happen from pure TCL perspective. It's a side effect of TCL interpreter integration in Jenkins: I guess there's a hidden layer that parses the script and modify it according to non-TCL syntax. I would do 2 trials: First is to minimize the TCL parsings f the string:

foreach name $docker_names {
  set name "TestName"
  puts $name
  set command [concat {docker inspect --format='{{.Id}}'} $name { > /home/temp/id.txt} "\n"]
  send -- $command
  expect "$"
}

If it doesn't help, try backquoting the curlybraces that may be interpreted by another layer:

foreach name $docker_names {
  set name "TestName"
  puts $name
  set command "docker inspect --format='\{\{.Id\}\}' ${name} > /home/temp/id.txt"
  send -- "$command\n"
  expect "$"
}
Related