Publishing and Retrieving an Artifact
To ensure traceability in processes, output needs to be versioned and tracked as it is handed from one process stage to another. With CloudBees CD Artifact Management, implementing your processes is auditable and secure.
This tutorial shows how to produce and consume artifacts as part of a CloudBees CD process.
To view an example procedure for this tutorial , go to the automation platform UI > Projects > EC-Tutorials- <version> , and click the procedure name.
An explanation of what you see—the following concepts are illustrated in this procedure:
The first five steps are simple ec-perl scripts that create files and directories as use as an artifact.
The first step, "Create myartifact.txt file", creates a text file in a workspace that can be added as an artifact. Click this step to go to the Edit Step page to see the full "dummy" script used to set up the artifact in the Command(s) field. This script creates a file named
There is no code specific to CloudBees CD in this step, so understanding the Perl code used to generate the text file is not necessary.
The next four steps create a directory, a subdirectory and the second text file in it.
The "Publish artifact" step calls the EC-Artifact:Publish procedure. This step is configured to place the file
myartifact.txt, created in the Setup step, into an artifact.
To do this, the EC-Artifact: Publish procedure requires the following information: The artifact where you want to publish. This is in the format
Artifact Group:Artifact Key. In this case, the name of the artifact (where you want to publish) is EC-Tutorials:MyArtifact. The artifact version being published. The version is in the form of
major.minor.patch.buildnumber-qualifier. For this tutorial, the version is set to
1.0.$[jobId]-tutorial. Using the
$[jobId]property expansion results in a new artifact being created every time the procedure is run. ** The repository server from which you need to retrieve the artifact. This tutorial uses a repository named
defaultthat was created when CloudBees CD was installed.
+ To see how this information is specified in this step, click the "Publish artifact" step name to go to the Edit Step page.
The "Retrieve artifact" step calls the EC-Artifact: Retrieve procedure. This step takes two required parameters and several optional parameters (see the Edit Step page/Parameter section for this step). The required parameters are:
Artifact – EC-Tutorials:MyArtifact (this is the name of the artifact to retrieve).
1.0.$[jobId]-tutorial(this is the artifact version to be retrieved—either an exact version or a version range). This tutorial uses an exact version.
The optional parameters are:
Retrieve to directory – the location where the artifact files are downloaded when they are retrieved. This is where the retrieved artifact versions are stored.
Overwrite – the default is update where the artifact files are updated when they are retrieved. The other values are true (the files for the retrieved artifact versions are overwritten) or false (the files for the the retrieved artifact versions are not overwritten).
The Retrieved Artifact Location Property parameter is the name or property sheet path that the step uses to create a property sheet. The default value is ` /myJob/retrievedArtifactVersions/$[assignedResourceName]`.
This property sheet has information about the retrieved artifact versions, including their location in the file system. It displays the location from where the artifact is to be retrieved and retrieves the property value in the
For the Filter(s) parameter, enter search filters, one per line, applicable to querying the CloudBees CD database for the artifact version to retrieve.
For more information about these parameters, see Retrieve Artifact Version Step.
The "Output location that artifact was retrieved to" step prints the message "Artifact extracted to: <directory where the retrieved artifact will be located>".
Click Run to run this sample procedure and see the resulting job on the Job Details page.
To publish and retrieve artifacts, apply these concepts to your artifact projects, creating the steps as required to your procedure.
|Any changes you make within this tutorial will not be saved when you upgrade CloudBees CD.|