6 - Artifact Build and Deploy Pipelines
Pipelines define your release process using multiple Workflows and approvals in sequential and/or parallel stages. And Artifact Build and Deploy Pipeline simply runs your Build Workflow followed by your Deploy Workflow. The Deploy Workflow uses the Harness Service you set up to get the new build number.
Using Build Workflows in a Pipeline
Here are some important things to remember when using a Build Workflow in a Pipeline:
- No Artifact Selection — If you use a Build Workflow in a Pipeline, you cannot select an artifact when you deploy the Pipeline. A Build Workflow tells Harness you will be building and collecting the artifact for the Pipeline. Harness will use that artifact for the Pipeline deployment.
- Don't Execute in Parallel — Do not execute a Build Workflow in a Pipeline in parallel with a Workflow that deploys the artifact built by the Build Workflow. The Build Workflow must complete before another Workflow in the Pipeline can deploy the artifact.
- Always Put Build Workflow First — The Build Workflow should always be the first stage in the Pipeline. This enables the rest of the Pipeline to use the artifact it builds and collects.
Create the Build and Deploy Pipeline
To create the Artifact Build and Deploy Pipeline, do the following:
- In your Harness Application, click Pipelines, and then click Add Pipeline. The Add Pipeline dialog appears.
- In Name, enter a name for your Pipeline, such as Artifact Build and Deploy.
- Click SUBMIT. The new Pipeline is created.
Add the Build Workflow as the first stage in the Pipeline:
- In Pipeline Stages, click the plus button. The Pipeline Stage dialog appears.
- In Step Name, enter a name for the Build Stage, such as Build Artifact.
- In Execute Workflow, select the Build Workflow you created. When you are done, it will look something like this:
- Click SUBMIT. The stage is added to the Pipeline.
- Use the same steps to add the Deploy Workflow to the Pipeline. When you are done, it will look something like this:
- Click Deploy to run the Pipeline. Note that you do not need to select an artifact build number as the Deploy Workflow will obtain the latest build.
- Click SUBMIT.
The Workflows are run in succession. First, the Build Workflow is run. Click the Artifact Collection step to see the metadata collected by Harness, including the build number:
You can see the same build number in Jenkins:
Next, the Deploy Workflow is run. Click the Artifact Check step to see the same build number that was collected by the Artifact Collection step. You can also see the build number next to the Artifacts heading.
The Pipeline has been run successfully. You can now build and deploy artifacts by running a single Pipeline.