コード例 #1
0
// If we were running in an lxc container, the artifacts are already grouped
// but they need to be removed from the container and placed in the actual
// artifact destination. Because we pass through the Jenkins environment
// variables to the commands inside of the container, we expect that they
// be in the same location as we expect them to be, except nested within
// the mounted filesystem.
func (r *Reporter) PublishArtifacts(cmdCnf client.ConfigCmd, a adapter.Adapter, clientLog *client.Log) {
	if a.GetRootFs() == "/" {
		log.Printf("[reporter] RootFs is /, no need to move artifacts")
		return
	}

	artifactSource := path.Join(a.GetRootFs(), r.artifactDestination)
	log.Printf("[reporter] Moving artifacts from %s to: %s\n", artifactSource, r.artifactDestination)
	cmd := exec.Command("mkdir", "-p", artifactDestination)
	err := cmd.Run()
	if err != nil {
		log.Printf("[reporter] Failed to create artifact destination")
	}
	cmd = exec.Command("cp", "-f", "-r", path.Join(artifactSource, "."), r.artifactDestination)
	err = cmd.Run()
	if err != nil {
		log.Printf("[reporter] Failed to push artifacts; possibly the source artifact folder did not exist")
	}
}