2 - Service and Artifact Source
Harness Services represent your microservices/apps. You define where the artifacts for those microservices/apps come from, and the container specs, configuration variables, and files for those microservices.
The first step in an Artifact Build and Deploy pipeline is to create a Harness Service that connects to the Artifact Server you added in Harness Account Setup and identifies the artifact to deploy. The Service also contains the scripts used to install and run the build on the target nodes.
To create the Service, do the following:
- In your Harness Application, click Services. To create a Harness Application, see Application Components.
- Click Add Service. The Add Services dialog appears.
- In Name, enter a name for your Service. We are going to build a ToDo List app and package it in a WAR file, so we will name the Service ToDo List WAR.
- In Deployment Type, we will select Secure Shell (SSH).
- In Artifact Type, we will select Web Archive (WAR).
- In Application Stack, we will select Standard Tomcat 8.
- Click SUBMIT.
The new Service is created. As you can see there are several installation and start scripts added by default. When your application is deployed, these scripts are run on the target host(s).
Next, we will add the Artifact Source.
Add Artifact Source
The Artifact Source defines where the Artifact Collection step will look for the built artifact during the Build Workflow. Also, the Service is used in the Deploy Workflow to install the artifact on the target host(s).
To add an Artifact Source, do the following:
- In your Service, click Add Artifact Source, and select Jenkins. The Jenkins dialog appears.
- In Source Server, select the Jenkins Artifact Server you set up in Harness Account Setup. Once you select the Source Server, the Job Name field will load all of the Jenkins jobs from the Source Server.
- In Job Name, select the job you want to run to build your artifact. Harness also supports Jenkins Multibranch Pipelines.
- Select the Meta-data Only setting. Typically, metadata is sufficient as it contains enough information for the target host(s) to obtain the artifact. Harness stores the metadata and, during runtime, the Harness Delegate passes the metadata to the target host(s) where it is used to obtain the artifact(s) from the source repo. Ensure that the target host has network connectivity to the Artifact Server.
- In Artifact Path, select the path and name of the artifact. In our example, we use target/todolist.war.
When you are done, the Jenkins Artifact Source will look something like this:
- Click SUBMIT.
The Artifact Source is added to the Service.
Next, let's see the artifact history that Harness can pull from Jenkins.
- Click Artifact History.
- Click Manually pull artifact. The Manually Select An Artifact dialog appears.
- In Artifact Stream, select the artifact source you just added.
- In Artifact, select the build you want history on.
- Click SUBMIT.
- Click Artifact History again. The history for the build you specified is displayed.
Now, that the Service is complete, we can create the Build Workflow to build the next version of the artifact.
For more information on Service settings, see Services.