4

Using GoCD, how can I define a stage's entire workspace (as a single artifact) for the next stage? This would highly simplify my setup, in which the second stage needs to fetch many different artifacts from the previous one.

I have tried the following artifact declarations:

  1. Artifact source = .

This causes an error already during the upload in the first stage:

[go] The rule [.] cannot match any resource under [pipelines/mypipeline]
[go] [go] Uploading finished. Failed to upload [.]
  1. Artifact source = *

This does not cause errors, but causes a separate upload for each directory in the root folder, instead of a single artifact of the entire workspace. As a result, I still need to fetch multiple concrete artifacts, instead of one big workspace artifact.

[go] Uploading artifacts from /var/lib/go-agent/pipelines/mypipeline/.svn to [defaultRoot]
[go] Uploading artifacts from /var/lib/go-agent/pipelines/mypipeline/cruise-output to [defaultRoot]
[go] Uploading artifacts from /var/lib/go-agent/pipelines/mypipeline/<dir1> to [defaultRoot]
[go] Uploading artifacts from /var/lib/go-agent/pipelines/mypipeline/<...> to [defaultRoot]
[go] Uploading artifacts from /var/lib/go-agent/pipelines/mypipeline/<dirN> to [defaultRoot]

I could probably zip everything myself with another task and define that as an artifact, but with GoCD already zipping and unzipping on its onw, I thought there must be a simpler solution to my problem.

dokaspar
  • 8,186
  • 14
  • 70
  • 98

1 Answers1

0

I am not an expert, just a newbie with GoCD, but having gone through the same pain of trial and error, I'll share the syntax I found to work from my experience. For build artifacts in an upstream pipeline:

  • Source: #{BUILD_DIR}/*.whl - it seems wild card syntax works when defining build artifacts; NOTE: the values between the curly braces {XXX_XX} are pipeline parameters.
  • Destination: #{ARTIFACT_DIR} - I prefer to put all my artifacts in a separate folder as it is easier to fetch. GoCD will zip and transfer the folder and unzip it in the downstream pipeline.

In downstream pipeline or another stage in the same pipeline when retrieving artifacts using "Fetch Artifact" task:

  • Source: #{ARTIFACT_DIR} - I use only the directory name to fetch the entire directory
  • Destination ./ - the fetched directory will be extracted in current folder in this case

NOTE: The above syntax is for fetching directory of artifacts only where the Source is a file(Not a directory) checkbox in the "Fetch Artifact Task" is not selected.

I was not able to fetch artifact files when I tried parametrizing a file name with pipeline parameters or environment variables (for example my file artifact contained a dynamically generated version) and I did not find anything in the GoCD documentation or examples suggesting it is possible. The docs have example of downloading a file name that is a constant and does not change.

Please share examples of parametrizing file artifacts if possible or suggested workarounds if possible at all.

Emil
  • 2,196
  • 2
  • 25
  • 24