vRealize Automation - Code Stream Header

vRA Code Stream – Preserving files and artifacts created in a CI Task

Whilst creating a pipeline and using CI Tasks to run some CLI tools, I needed to save the outputted files from the container used for the CI Task so I could use them once the pipeline is completed.

Code Stream has a feature for CI Tasks called “Preserve Artifacts” to enable this, where by files in your working directory are saved to the “/sharedPath” folder location of the Docker Host where your container runs.

Below I’m going to show you how to use this feature.

  • First on your pipeline configure a Working Directory

Code Stream - Preserve Artifacts - Pipeline - Workspace - Working Directory

  • On your CI task steps move your outputted files to your Working Directory folder.
    • In my example I will have SSH key files created in ~/.ssh so I need to move them to my folder /workingDir which is specified at the previous steps
  • Under the “Preserve Artifacts” section of the CI Task, specify the filenames you want to be preserved.

Code Stream - Preserve Artifacts - Pipeline - Model - CI Task - Specify the paths of the artifact to preserve

  • Now run your Pipeline, open the execution and on the CI Task where your artifacts are created you will see the details of where these files are located on your Docker Host.
    • If you view the Output JSON, you can see the details you can use as outputs to reference in further tasks in the pipeline.

Code Stream - Preserve Artifacts - Pipeline Execution - Output - Preserve artifacts location

As an example, here I’ve setup an email notification on my pipeline task that sends me the location of the artifact on the docker host.

Code Stream - Preserve Artifacts - Pipeline - Model - CI Task - Create Notification

Code Stream - Preserve Artifacts - Pipeline - Model - CI Task - Create Notification

Here is a quick screenshot of the email from the above example.

Code Stream - Preserve Artifacts - Pipeline - Model - CI Task - Email Notification Example

  • Log onto your Docker Host, and browse to the location provided on the Output

Code Stream - Preserve Artifacts - Docker Host - Location

Thanks to Sam McGeown for his assistance with this! Sam has also wrote a great guide on how you could publish your artifacts via a web server, so that a user does not have to access the docker host, nor do they  have access to confidential logs.



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.