7

I'm running a TeamCity agent that spawns a docker container, running several tasks inside that (php) container. Such as phpunit, phplint and composer. I zipped the content inside the container if all tests pass, it will create a phpproject.zip.

After it's done I would like to push that phpproject.zip as an Artifact back to the TeamCity server from inside the docker container.

My docker container is running with the --rm parameters to remove the container after the script is done.

Is this possible?

Tim

Tim Ververs
  • 527
  • 9
  • 23

2 Answers2

6

You can map a volume of the Docker daemon to the container with the -v parameter and publish the artifacts to the daemon:

...
# Your build path and build command here
VOLUME /foo/build
ENTRYPOINT make

In TeamCity, configure a Docker build step to build the Dockerfile, and name:tag the resulting image. Add a second step in which you configure an other... Docker command as run, with the arguments:

-v /tmp/build:/foo/build --rm <name of image>

The result is then available in /tmp/build on the agent, and you can configure that as artifact path in the project's settings, or alternatively echo "##teamcity[publishArtifacts '/tmp/build']" somewhere.

deceze
  • 510,633
  • 85
  • 743
  • 889
Tim Ververs
  • 527
  • 9
  • 23
0

I guess you could also do a

id=$(docker create <name of image>)
docker cp $id:/path-in-docker-container /path-on-server
docker kill $id
docker rm $id
daniel kullmann
  • 13,653
  • 8
  • 51
  • 67