Information for: DEVELOPERS   PARTNERS

About build artifacts

After the build is complete, Pipelines creates a “build artifact” consisting of the contents of the SOURCE_DIR and commits the artifact to your Cloud Platform repository in a build branch named pipelines-build-[BRANCHNAME] by default.

Pipelines commits build artifacts automatically and does not log the results of the commit. However, the pipelines start command does display the path of the build branch in the repository.

Why is the build artifact created in the repository?

Storing the build artifact in your Cloud Platform repository provides the following advantages over alternatives such as creating a tarball:

  • You can easily deploy the build artifact to your Cloud Platform environments, using the Cloud Platform interface or the Cloud API.
  • You can easily view the build artifact using Git.
  • You can more easily debug your build process, comparing the build artifact against what you may have expected, and compare build artifacts over time, using a tool like git diff.
  • You can control how long your build artifacts are retained, since you control the contents of your own repository. You may, for example, have compliance requirements that mandate keeping them for a specified time, or security concerns that require you to be able to delete them promptly.
  • You can easily copy a build artifact to other systems for such purposes as static code analysis or license compliance.

Deploying the build artifact

After you have successfully completed a build, you can deploy the resulting build artifact in any Cloud Platform environment. You can do this by selecting the build branch for deployment, using either of the following methods:

  • Directly in the Cloud Platform interface
  • By using the Cloud API

After you set the deployed branch of an environment to a build branch, each build artifact committed to that branch is deployed immediately, without requiring any intervention. For example, if you build the master branch, and your Cloud Platform development environment is set to the pipelines-build-master branch, the build artifact is deployed immediately to that development environment when the pipeline job completes successfully.

Node.js build artifacts

Node.js application support in Cloud Platform uses the Cloud Platform pipelines functionality to build an artifact that you can then deploy to your environment.

Each artifact has a name, which enables you to select a specific artifact by that name in the deployment phase. When you deploy, the most recently built artifact will be at the top of the list. The default naming convention for node artifacts is as follows:

[git branch]@[commit hash]

This can cause issues, as commits can be amended. This can result in two artifacts with the same name but with different comments.

It is possible to set a default name for your artifact by adding configurations to your yaml file using the pipelines-artifact command and pipelines variables. To do this, complete the following steps:

  1. Edit your build definition file. For examples, see Example pipelines build definition files.

  2. Find the following line in the file:

    - pipelines-artifact start
    
  3. Edit the line by adding the PIPELINE_VCS_PATH and PIPELINE_GIT_HEAD_REF options to your start command, similar to the following:

    - PIPELINE_VCS_PATH=artifact PIPELINE_GIT_HEAD_REF=example pipelines-artifact start
    
  4. Save the build definition file.

Using this example, your artifact name will become artifact@example rather than branch@commit.