Smartsheet - Harness

Hey All!

I’ve had a few conversations around integrations with Harness and other tools, what is and is not supported, and even when certain integrations will be coming. One of the great things about a Software-as-a-Service like Harness is that you get rapid integration support with use-case-directed development.

Obviously, we will need to supplement a stop-gap for some of these integrations in the meantime. The technology integration that this post covers will be Smartsheet.

Smartsheet Information

There are somethings that will need to be brought in from Smartsheet for you to use this integration:

  1. Sign-in to Smartsheet

  2. Click your User icon in top right

  3. Click “Personal Settings…”
    image

  4. Click “API Access”

  5. Generate a new token called “Harness”

  6. Copy the token and place it in the Harness Secrets Manager as “smar_token”

Smartsheet Sheet information:

  • Sheet name
  • Column Names to interact with (i.e. Status, Title, Description)
  • Status Types (i.e. “Ready for Testing”, “Ready for QA”, “Approved”)

Harness: Template Library

Smartsheet uses a sheet row to indicate the tickets or issues that you can use. As such, we want to be able to create and/or update those rows throughout the Harness Workflows and/or Pipelines. Therefore, we will be creating two templates in the Harness Template Library: smartsheet_create and smartsheet_update

The template for the smartsheet_create is found here.

This template will execute the desired Row Create command and output the Row ID and Discussion ID into the variable ROW_ID and DISCUSSION_ID (for later use). Some things to notice when setting up the template:

  1. Make sure you add the following pieces as variables in the Template Modal:
    a. SHEET (set to ${workflow.variables.sheet_name})
    b. MSG (set to ${workflow.variables.msg})
    c. TOKEN (set to ${secrets.getValue("smar_token")})
    d. URL (set to https://api.smartsheet.com/2.0/sheets)
    e. STATUS (set to ${workflow.variables.status})
    f. SUBJECT (set to title column name)
    g. DESCRIPTION (set to description column name)
    h. COL_S (To designate the Status column)
    i. COL_T (To designate the Title column)
    j. COL_D (To designate the Description column)

Lastly, add ROW_ID,DISCUSSION_ID in the Script Output section

Once you have this in the Template Library, you can make the smartsheet_update template (found here)

The template has some variables for it as well:
a. SHEET (set to ${workflow.variables.sheet_name})
b. MSG (set to ${workflow.variables.msg})
c. TOKEN (set to ${secrets.getValue("smar_token")})
d. URL (set to https://api.smartsheet.com/2.0/sheets)
e. STATUS (set to ${workflow.variables.status})
f. COL_S (set to Status column name)
g. ROW_ID (set to ${context.smar.ROW_ID} which we will leverage from the workflow)
h. DISCUSSION_ID (set to ${context.smar.DISCUSSION_ID} which we will leverage from the workflow)

After both of these are done in the Template Library, you will want to link them in the desired Harness Workflow.

Harness: Workflow

To start off, we will want to make sure that the Workflow Variables are set correctly:

Add the correct Status types as comma-separated-values in the Allowed Values section (i.e. “Ready for Testing”,“Ready for QA”,“Approved”,“Rejected”)

Now, we will want to add a step in the pre-deployment part of the Workflow and link the smartsheet_create template:

If you would like to add an approval step to this as well, you can add the Approval Step and use the Custom Shell Script with this script (Make sure that you change the DES_STATE value if you want something different than Approved as your Approval State).

A few things of importance here are:

  1. Add the tag you assigned to the delegate in the Tags section
  2. Check the box that says “Publish output in the context” in the smartsheet_create Template
    a. Publish Variable Name = ss
    b. Scope = Pipeline
    c.
  3. If you did not fill in the variable values in the Template Library, make sure to do that now

Deployment

(Note: Not all read in the context is bad, so keep that in mind)

image




You can also leverage the update template across multiple workflows in the same pipeline and even use the approval script as the approval gate to prevent non-tracked deployments from going into a higher-level environment.

Hopefully this helps!

Don’t forget to Like/Comment/Share!

2 Likes