Bat file executed in Docker image fails to wait for previous command

Hello all,

In hopes of building my C++ project, I am using a windows orb/executor to run a Docker image that contains my C++ build environment. The project is built by copying the project repository onto the docker image, and then executing a bat file that is found within the project repository. This bat file handles the actual build steps, first doing some file cleanup (rmdir, mkdir, xcopy), and then running msbuild and wixinstaller. The Docker image is able to successfully build the project on my local machine. When attempting to run the build on circleci, it seems to go all good, up until the point of executing the bat file. It seems that the docker container fails to wait for the previous command in the bat file to finish. I have attempted to run the bat file commands in separate steps that are called into the container through “docker exec [container name] [command]”, but encounter a “container container ID is not running” error. I have also attempted to run docker/command prompts in interactive mode in hopes that they will wait, with no luck. This is my first time working with tools of this sort, so I apologize for any silly mistakes. In the end, any help is appreciated. Thanks.

Solved the issue after a good bit of struggle and wanted to update this in order to potentially help anyone facing similar issues. First, inside of my build script I was making use of a “cd %~dp0” command in an effort to later use a “mkdir tmp” command in the same directory of the script I was running. There was a flaw in this, in that, it seems the windows executor runs with escalated privileges. As a result of running with escalated privileges, it is necessary to supply absolute file paths (ie. I needed to use “mkdir %~dp0tmp”). Furthermore, the build script that was initially being executed called into several layers of bat files. From what I have gathered, this results in the bat files not waiting for returned status codes from the bat files that are called into. As a result, I centralized all of the bat files into a single bat file, which is then executed through my docker image’s entrypoint. After these changes I was able to successfully build and artifact my necessary files. Hopefully this can help anyone facing similar issues down the line.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.