Harness Workflow Template

Khanh PhanKhanh Phan
2 min read
harnessApiVersion: '1.0'
type: ROLLING
concurrencyStrategy: INFRA
description: <Replace This>
failureStrategies:
- executionScope: WORKFLOW
  failureTypes:
  - APPLICATION_ERROR
  repairActionCode: ROLLBACK_WORKFLOW
  retryCount: 0
notificationRules:
- conditions:
  - FAILED
  executionScope: WORKFLOW
  notificationGroupAsExpression: false
  userGroupAsExpression: false
  userGroupNames:
  - <Replace This>
phases:
- type: KUBERNETES
  computeProviderName: <Replace This>
  daemonSet: false
  infraDefinitionName: <Replace This>
  name: Rolling
  phaseSteps:
  - type: K8S_PHASE_STEP
    name: Deploy
    stepSkipStrategies:
    - assertionExpression: ${context.<Replace This>.<Replace This>}=="<Replace This>"
      scope: SPECIFIC_STEPS
      steps:
      - <Replace This>
    steps:
    - type: SHELL_SCRIPT
      name: Run <Replace This>
      properties:
        commandPath: null
        connectionAttributeName: null
        executeOnDelegate: true
        host: null
        includeInfraSelectors: true
        outputVars: <Replace This>
        publishAsVar: true
        scriptString: <Replace This>
        scriptType: BASH
        secretOutputVars: ''
        sshKeyRefName: null
        sweepingOutputName: <Replace This>
        sweepingOutputScope: PIPELINE
        templateExpressions: null
        templateUuid: null
        templateVariables: null
        templateVersion: null
        timeoutMillis: 60000
    - type: APPROVAL
      name: Approval
      properties:
        approvalStateType: USER_GROUP
        description: ''
        timeoutMillis: 86400000
        userGroupNames:
        - Account Administrator
    stepsInParallel: false
  - type: K8S_PHASE_STEP
    name: Verify
    stepsInParallel: false
  - type: K8S_PHASE_STEP
    name: Wrap Up
    stepsInParallel: false
  provisionNodes: false
  statefulSet: false
  templateExpressions:
  - expression: ${Service}
    fieldName: serviceId
    metadata:
    - name: relatedField
    - name: artifactType
      value: DOCKER
    - name: entityType
      value: SERVICE
  - expression: ${InfraDefinition_KUBERNETES}
    fieldName: infraDefinitionId
    metadata:
    - name: relatedField
    - name: entityType
      value: INFRASTRUCTURE_DEFINITION
rollbackPhases:
- type: KUBERNETES
  computeProviderName: <Replace This>
  daemonSet: false
  infraDefinitionName: <Replace This>
  name: Rollback Rolling
  phaseNameForRollback: Rolling
  phaseSteps:
  - type: K8S_PHASE_STEP
    name: Deploy
    phaseStepNameForRollback: Deploy
    statusForRollback: SUCCESS
    steps:
    - type: K8S_DEPLOYMENT_ROLLING_ROLLBACK
      name: Rollback Deployment
    stepsInParallel: false
  - type: K8S_PHASE_STEP
    name: Wrap Up
    phaseStepNameForRollback: Wrap Up
    stepsInParallel: false
  provisionNodes: false
  statefulSet: false
  templateExpressions:
  - expression: ${Service}
    fieldName: serviceId
    metadata:
    - name: relatedField
    - name: artifactType
      value: DOCKER
    - name: entityType
      value: SERVICE
  - expression: ${InfraDefinition_KUBERNETES}
    fieldName: infraDefinitionId
    metadata:
    - name: relatedField
    - name: entityType
      value: INFRASTRUCTURE_DEFINITION
templateExpressions:
- expression: ${Environment}
  fieldName: envId
  metadata:
  - name: relatedField
    value: ${InfraDefinition_KUBERNETES}
  - name: entityType
    value: ENVIRONMENT
- expression: ${Service}
  fieldName: serviceId
  metadata:
  - name: relatedField
  - name: artifactType
    value: DOCKER
  - name: entityType
    value: SERVICE
- expression: ${InfraDefinition_KUBERNETES}
  fieldName: infraDefinitionId
  metadata:
  - name: relatedField
  - name: entityType
    value: INFRASTRUCTURE_DEFINITION
templatized: true
userVariables:
- type: ENTITY
  description: Variable for Environment entity
  fixed: false
  mandatory: true
  name: Environment
- type: ENTITY
  description: Variable for Service entity in Rollback Rolling
  fixed: false
  mandatory: true
  name: Service
- type: ENTITY
  description: Variable for Infrastructure Definition entity in Rollback Rolling
  fixed: false
  mandatory: true
  name: InfraDefinition_KUBERNETES

Email notification:

  notificationRules:
    - name: Pipeline Running Failed Notification
      identifier: Pipeline_Running_Failed_Notification
      pipelineEvents:
        - type: StageFailed
          forStages:
            - AllStages
        - type: PipelineFailed
        - type: StepFailed
      notificationMethod:
        type: Email
        spec:
          userGroups: []
          recipients:
            - <email-address>
      enabled: true
  variables:
0
Subscribe to my newsletter

Read articles from Khanh Phan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Khanh Phan
Khanh Phan

DevOps Engineer