2 - Service and Artifact Source

Updated 2 months ago by Michael Cretzman

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.

This Service is used by the Artifact Collection command in the Build Workflow, the Environment, and in the set up of the Deploy Workflow.

Create Service

To create the Service, do the following:

  1. In your Harness Application, click Services. To create a Harness Application, see Application Components.
  2. Click Add Service. The Add Services dialog appears.
  3. 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.
  4. In Deployment Type, we will select Secure Shell (SSH)
  5. In Artifact Type, we will select Web Archive (WAR).
  6. In Application Stack, we will select Standard Tomcat 8.
  7. 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).

For more information about the default scripts in a Secure Shell (SSH) Service, see Traditional Deployments Overview.

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:

  1. In your Service, click Add Artifact Source, and select Jenkins. The Jenkins dialog appears.
  2. 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.
  3. In Job Name, select the job you want to run to build your artifact. Harness also supports Jenkins Multibranch Pipelines.
  4. 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.
  5. 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:

  1. Click SUBMIT.

The Artifact Source is added to the Service.

Next, let's see the artifact history that Harness can pull from Jenkins.

  1. Click Artifact History.
  2. Click Manually pull artifact. The Manually Select An Artifact dialog appears.
  3. In Artifact Stream, select the artifact source you just added.
  4. In Artifact, select the build you want history on.
  5. Click SUBMIT
  6. 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.

Next Step

How did we do?