Building Go Pipelines with Harness CI

Aug 5, 2024

Lecture Notes: Building a Simple Go Pipeline on Harness CI

Introduction

  • Presenter: Davajati from the Community Engine team at Harness
  • Topic: Introduction to Harness CI and building a simple Go pipeline on RS Cloud
  • Summary: Discuss how to use Harness CI, a fully managed CI solution, to build and test code without maintaining own infrastructure.

Prerequisites

  1. Harness Account: Hosted on app.harness.io
  2. GitHub Account: Acts as the source code manager
  3. Docker Hub Account: Serves as the Docker registry

Steps to Get Started

  • Fork Repository: Use the Go pipeline sample from the Harness Community repository.
  • Sign Up for Harness: Create an account on app.harness.io using email, Google, or GitHub.
  • Email Verification: Verify email to activate the account.

Setting Up the Pipeline

  1. Signing In: Use Google, GitHub, or email to sign into Harness.
  2. Choose CI Module: Select CI module from the Harness homepage.
  3. Select Source Code Manager: Choose GitHub for this example and authenticate.
  4. Select Repository: Choose the Go application sample repository from GitHub.
  5. Configure Pipeline: Use starter pipeline configuration and create pipeline.

Pipeline Configuration

  • Default Configuration: Hosted builds on Linux with am64 architecture.
  • Run Step: Displays a welcome message - “Welcome to Harness CI”
  • Execution Views: Visual and console views available.

Running the Pipeline

  • Click on Run: Fetches the main branch and starts execution.
  • Execution Panels: Visual and console views show live execution status.

Modifying the Pipeline

Step 1: Run Unit Tests

  • Rename Run Step: Change to “Run Unit Tests”
  • Command Line: Auto-populate with unit test commands for Go application.
  • Container Registry: Define as runtime input, use Golang image.
  • Test Results Path: Define path to store test results.

Step 2: Build Application

  • Run Step Name: “Build App”
  • Command Line: Auto-populate with build commands.
  • Container Registry: Define as runtime input, use Golang image again.

Step 3: Build and Push Image

  • Run Step Name: “Build and Push Image to Docker Hub”
  • Docker Connector: Define as runtime input, use Docker Hub credentials.
  • Tags: Use “latest” as default tag.

Running and Verifying the Pipeline

  • Run Pipeline: Fetches main branch and executes with live status updates.
  • Docker Connector: Define and authenticate Docker registry connection.
  • Test Results: Track unit test results during execution.
  • Previous Executions: Check execution history for the pipeline.
  • Triggers: Use triggers for automated pipeline executions for GitHub events.

Optimizing Runtime Inputs

  • Save Input Set: Save defined runtime inputs as a new input set.
  • Reuse Input Set: Use saved input sets for future executions to avoid manual input.

Conclusion

  • Support: Join the Slack channel of the Harness community for queries.
  • Thank You: Appreciation for joining the session.