No escaping of variables in docker wrapper scripts in 2017.2

Hi,

We hit an issue when trying your docker integration today (2017.2). It looks like the wrapper script you are using to pass data to the process inside the docker container is incorrect when the ec2 plugin is installed.

On a local agent (running directly on the host), a "Maven" build step using a custom docker image return this error:

[18:10:59]Step 2/5: Build (Maven) (2s)
[18:11:00]Initial M2_HOME not set
[18:11:00]Current M2_HOME = /opt/TeamCity/buildAgent/tools/maven3_3
[18:11:00]PATH = /opt/TeamCity/buildAgent/tools/maven3_3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
[18:11:00]Using watcher: /opt/TeamCity/buildAgent/plugins/mavenPlugin/maven-watcher-jdk16/maven-watcher-agent.jar
[18:11:00]Initial MAVEN_OPTS not set
[18:11:00]Current MAVEN_OPTS not set
[18:11:00]Starting: /bin/sh -c docker pull <MY_DOCKER_IMAGE>/build && docker run --rm -w "/opt/TeamCity/buildAgent/work/d5cfb98c708886f2" --volume "/home/teamcity/.m2:/root/.m2" --volume "/home/teamcity/.npm:/root/.npm" --volume "/home/teamcity/.npmrc:/root/.npmrc" -v "/opt/TeamCity/buildAgent/work/d5cfb98c708886f2:/opt/TeamCity/buildAgent/work/d5cfb98c708886f2" -v "/opt/TeamCity/buildAgent/temp/agentTmp:/opt/TeamCity/buildAgent/temp/agentTmp" -v "/opt/TeamCity/buildAgent/temp/buildTmp:/opt/TeamCity/buildAgent/temp/buildTmp" -v "/opt/TeamCity/buildAgent/system:/opt/TeamCity/buildAgent/system" -v "/opt/TeamCity/buildAgent/lib:/opt/TeamCity/buildAgent/lib:ro" -v "/opt/TeamCity/buildAgent/tools:/opt/TeamCity/buildAgent/tools:ro" -v "/opt/TeamCity/buildAgent/plugins:/opt/TeamCity/buildAgent/plugins:ro" --env-file "/opt/TeamCity/buildAgent/temp/agentTmp/docker-wrapper-6118212050918044843.env" --entrypoint "/bin/sh" "<MY_DOCKER_IMAGE>/build" "/opt/TeamCity/buildAgent/temp/agentTmp/docker-shell-script-4515732364777039942.sh"
[18:11:00]in directory: /opt/TeamCity/buildAgent/work/d5cfb98c708886f2
[18:11:00]Using default tag: latest
[18:11:00]latest: Pulling from build
[18:11:00]Digest: sha256:<MY_DIGEST>
[18:11:00]Status: Image is up to date for<MY_DOCKER_IMAGE>/build:latest
[18:11:00]Cannot find '/usr/lib/jvm/java-8-oracle/bin/java' in Docker image, will use 'java' instead
[18:11:00]/opt/TeamCity/buildAgent/temp/agentTmp/docker-shell-script-4515732364777039942.sh: 23: /opt/TeamCity/buildAgent/temp/agentTmp/docker-shell-script-4515732364777039942.sh: Syntax error: "(" unexpected
[18:11:00]Process exited with code 2
[18:11:00]Process exited with code 2
[18:11:02]Step Build (Maven) failed
 
When I looked in my fs for `/opt/TeamCity/buildAgent/temp/agentTmp/docker-shell-script-4515732364777039942.sh`, I could see that you defined a lot of arguments in bash, except that the argument ec2.ami-manifest-path with value "(unknown)" (from memory, I am sure it contained parenthesis) was not escaped.
 
0
4 comments
Avatar
Permanently deleted user

to be more clear, the string in the bash script was:

-Dec2.ami-manifest-path=(unknown)

without escaping

0

Hi, 

Any updates on this? I experience the exact same issue. Simon, did you find any workaround that you can share? 

 

 

0
Avatar
Permanently deleted user

Hi, the relevant issue provided by the support was: https://youtrack.jetbrains.com/issue/TW-51918

It should have been fixed already (we found out that docker integration did not fit our need, so we are not using it, but during our tests we did not have the problem any more).

0

Thank you. 

For future reference, for this specific issue, you can override the system variable by explicitly defining it by yourself in the build properties. 

i.e 

system.ec2.ami-manifest-path with any value. 

0

Please sign in to leave a comment.