Jenkins getting test results from docker slave
Asked Answered
G

1

1

We have a jenkins setup with docker slaves, but somehow not all artifacts are available from within jenkins.

Our setup:

  • Jenkins Master running on a single VM
  • multiple Docker hosts setup on different VM's
  • We are using php-template
  • Docker containers are configured to run all tests required for our projects.
  • When a project is being build a docker container is spun up on one of the Docker hosts, tests are run, phing results are copied back to the host, the docker container is committed to an image and the running container is destroyed.
  • We are using the "copy to slave plugin" to copy our build directory from the slave to the master so all required artifacts are on the Jenkins master.

The problem is that when the build is completed that we are not able to view the workspace files (which we copied with the copy to slave plugin) We are also unable to link to the graphics files which have been copied to the master.

<img type="image/svg+xml" height="300" src="ws/build/pdepend/overview-pyramid.svg" width="500"></img>
<img type="image/svg+xml" height="300" src="ws/build/pdepend/dependencies.svg" width="500"></img>

We can however see these images during build when the docker container is still running.

What are we missing?

Gala answered 27/3, 2015 at 8:19 Comment(6)
I'm experiencing the same problem. I don't have a solution yet, but I suspect that when copy-to-slave plugin runs as post build step, docker container is already stopped, therefore none of the files are copied over.Bryant
Ah, but all files are copied to the workspace directory on the master server. These are just not accessible through the web-interface of jenkins. e.g. jenkins.server/job/project/ws Even if i set a custom project workspace in the advanced settings.Gala
Yes - you are right, the files are copied over fine. Jenkins just doesn't see it. When you click on workspace, I presume you see something like: The workspace directory (null) is removed outside Jenkins. while it should say: The workspace directory (/path/to/workspace) is removed outside Jenkins.. However, during the build process, the workspace is not empty, at least I can see files. It seems that Jenkins thinks that workspace is on remote machine. In standard slave setup it is OK, but with Docker container, which is stopped after build, it is not right.Bryant
Have a look here maybe it'll help.Bryant
I'm no java expert, but what i can tell from the code is that it facilitates the possibility to view the workspace when the Docker container is running. Unfortunately this is not the case when a build is done.Gala
I do not think you will be able to see the copied files on jenkins master via job workspace, because workspace always refer to the local slave workspace, If you want to see the content, you should archive via job configuration option it which can be accessible in future.Sappington
G
2

To update and close this question. I have solved this by adding the required files to the jenkins master as an reporting resource "Publish HTML reports" This way we can link to the missing files.

<img type="image/svg+xml" height="300" src="Pdepend_files/overview-pyramid.svg" width="500"></img>
<img type="image/svg+xml" height="300" src="Pdepend_files/dependencies.svg" width="500"></img>
Gala answered 23/4, 2015 at 10:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.