Claude
Skills
Sign in
Back

harness-expert

Included with Lifetime
$97 forever

Expert-level Harness template types, runtime inputs, expression language, pipeline patterns (CI/CD, GitOps, Canary, Blue-Green), versioning, and step configurations

Cloud & DevOps

What this skill does


# Harness Expert Skill

Expert knowledge of Harness template types, expression language, pipeline patterns, and deployment strategies.

## Harness Template Types

### 1. Step Templates

**Purpose:** Reusable step configurations across pipelines

**Types:**
- **ShellScript** - Execute bash/PowerShell scripts
- **Run** - Container step with image/command
- **K8sDeploy** - Kubernetes deployments
- **Http** - HTTP calls/webhooks
- **Approval** - Manual approval gates
- **ServiceNow** - ServiceNow integration
- **Custom** - Custom step plugins

**Template Structure:**
```yaml
template:
  name: Deploy to Kubernetes
  type: Step
  spec:
    type: K8sDeploy
    spec:
      service: <+input>
      environment: <+input>
      kubernetesCluster: <+input>
      namespace: <+input>
      releaseName: <+input>
      timeout: <+input.deployment_timeout>
      skipDryRun: false
      allowNoFilesFound: false
      delegateSelectors:
        - <+input.delegate_selector>
```

**Runtime Inputs (Required):**
```yaml
templateInputs:
  spec:
    service:
      serviceRef: <+input.service_name>
    environment:
      environmentRef: <+input.environment_name>
    kubernetesCluster:
      clusterId: <+input.cluster_id>
    namespace: <+input.k8s_namespace>
    releaseName: <+input.release_name>
```

---

### 2. Stage Templates

**Purpose:** Reusable stage definitions with multiple steps

**Template Structure:**
```yaml
template:
  name: Deploy Stage Template
  type: Stage
  spec:
    type: Deployment
    spec:
      service:
        serviceRef: <+input.service_ref>
      infrastructure:
        infrastructureDefinition:
          type: <+input.infra_type>  # Kubernetes, AWS, GCP, etc.
          spec: <+input.infra_spec>
      execution:
        steps:
          - step:
              name: Deploy
              identifier: deploy
              type: K8sDeploy
              spec:
                service: <+input.service_ref>
                environment: <+input.environment_ref>
          - step:
              name: Verify
              identifier: verify
              type: ShellScript
              spec:
                script: <+input.verify_script>
```

---

### 3. Pipeline Templates

**Purpose:** Full pipeline definitions with approval gates, notifications, conditions

**Template Structure:**
```yaml
template:
  name: Complete CI/CD Pipeline
  type: Pipeline
  spec:
    stages:
      - stage:
          name: Build
          identifier: build
          type: CI
          spec:
            codebase:
              repoName: <+input.repo_name>
              branch: <+input.branch>
              build:
                type: Docker
                spec:
                  dockerfile: Dockerfile
                  registryConnector: <+input.registry_connector>

      - stage:
          name: Deploy Dev
          identifier: deploy_dev
          type: Deployment
          spec:
            service:
              serviceRef: <+input.service_ref>
            environment:
              environmentRef: dev
            infrastructure:
              infrastructureDefinition:
                type: Kubernetes
                spec:
                  clusterId: <+input.dev_cluster_id>

      - stage:
          name: Approval
          identifier: approval
          type: Approval
          spec:
            approvalStepType: ShellScript
            script: echo "Deploying to production..."

      - stage:
          name: Deploy Prod
          identifier: deploy_prod
          type: Deployment
          spec:
            service:
              serviceRef: <+input.service_ref>
            environment:
              environmentRef: prod
            infrastructure:
              infrastructureDefinition:
                type: Kubernetes
                spec:
                  clusterId: <+input.prod_cluster_id>
```

---

## Runtime Inputs (`<+input>`) Syntax

### Basic Input Declaration

```yaml
spec:
  service:
    serviceRef: <+input>                    # Required, user must provide
  timeout: <+input.deployment_timeout>      # Optional with variable name
  replicas: <+input | default(3)>           # With default value
```

### Input Types & Examples

```yaml
String Input:
  image: <+input>
  service: <+input.service_name>

Number Input:
  timeout: <+input.timeout_minutes>
  replicas: <+input | default(3)>

Boolean Input:
  skip_tests: <+input | default(false)>
  enable_monitoring: <+input>

List/Array Input:
  environments: <+input.env_list>
  delegate_selectors: <+input.selectors>

Object Input:
  infrastructure: <+input.infra_spec>
```

### Conditional Inputs

```yaml
# Only required if another input is true
{{#if use_custom_image}}
  image: <+input.custom_image>
{{/if}}

# Conditional with expression
<+if>
  conditions:
    - key: environment
      operator: equals
      value: production
  then: <+input.prod_cluster>
  else: <+input.dev_cluster>
</+if>
```

---

## Expression Language Syntax

### Pipeline-Level Expressions

```yaml
# Access pipeline metadata
<+pipeline.name>                    # Pipeline name
<+pipeline.identifier>              # Pipeline identifier
<+pipeline.executionId>            # Execution ID
<+pipeline.triggeredBy>            # Who triggered it
<+pipeline.startTs>                # Start timestamp
<+pipeline.sequenceNumber>         # Execution sequence
```

### Stage-Level Expressions

```yaml
# Access stage metadata
<+stage.name>                      # Stage name
<+stage.identifier>                # Stage identifier
<+stage.status>                    # Stage status (Success, Failed, etc.)
<+stage.type>                      # Stage type (CI, Deployment, etc.)

# Stage variables
<+stage.variables.VARIABLE_NAME>   # Stage variable
<+stageArtifacts.IMAGE_ID>        # Output artifacts
```

### Step-Level Expressions

```yaml
# Access step outputs
<+steps.STEP_ID.output.outputKey>  # Step output variable
<+steps.build_docker.output.image> # Docker image from build step
<+steps.deploy.status>             # Step execution status

# Example
<+steps.deploy.deploymentStatuses> # Deployment status details
```

### Environment Variables

```yaml
<+env.JIRA_URL>                    # Environment variable
<+env.DOCKER_REGISTRY>             # From infrastructure

# Example in script
- step:
    type: ShellScript
    spec:
      script: |
        echo "Registry: <+env.DOCKER_REGISTRY>"
        docker push <+env.DOCKER_REGISTRY>/myapp
```

### Secret References

```yaml
# Retrieve secrets
<+secrets.getValue("my_secret")>           # Simple secret
<+secrets.getValue("vault://prod/db_pwd")> # Vault path

# Example
- step:
    type: ShellScript
    spec:
      environmentVariables:
        DB_PASSWORD: <+secrets.getValue("database_password")>
```

### Artifact & Output Expressions

```yaml
# Artifacts from previous stages
<+artifact.image>                  # Primary artifact
<+artifact.imageTag>               # Image tag
<+artifacts.COLLECTOR.IMAGE_ID>    # Named artifact

# Example in deploy
- step:
    type: K8sDeploy
    spec:
      image: <+artifact.image>:<+artifact.imageTag>
      service: <+input.service_ref>
```

---

## Pipeline Patterns

### Pattern 1: CI/CD Standard

**Description:** Standard continuous integration and deployment

**Flow:** Build → Test → Deploy Dev → Approval → Deploy Prod

```yaml
template:
  name: Standard CI/CD
  type: Pipeline
  spec:
    stages:
      # Stage 1: Build
      - stage:
          name: Build
          identifier: build
          type: CI
          spec:
            codebase:
              repoName: <+input.repo_name>
              branch: <+input.branch>
            build:
              type: Docker
              spec:
                dockerfile: Dockerfile
                registryConnector: <+input.docker_connector>
                imageName: <+input.image_name>
                imageTag: <+artifact.imageTag>

      # Stage 2: Test
      - stage:
          name: Test
          identifier: test
          type: CI
          depends:
        

Related in Cloud & DevOps