Build your first CI workflow

Learn how to build a CI workflow in Cloudbees Unify that automatically builds and tests a Go application. Create a component for a connected repository, define a multi-step job in the workflow composer, and trigger and verify a run.

Tutorial5 minute read

In this tutorial, we build a continuous integration (CI) workflow that automatically builds and tests a Go application every time code changes. No server setup or manual steps are required, as Cloudbees Unify runs the automation for you. By the end, we will have created a component for your connected repository, defined a multi-step CI job in the workflow composer, triggered and verified a run, and pushed a code change that kicks off the next one automatically.

Along the way, we meet the component, which ties your repository, workflows, and automation together in Cloudbees Unify.

Prerequisites

Before we begin, ensure you have completed the following. This tutorial uses a controlled sample app so we can focus on the workflow, not on debugging your own code.

Prerequisite Details

Cloudbees Unify access

You have component management permissions in at least one organization. Refer to RBAC permissions reference for permission details.

A connected repository

You have completed the Connect your repository tutorial and have a sample Go app repository connected to Cloudbees Unify.

The sample Go app

The repository contains a Go application with at least one test file (a file ending in _test.go).

Step 1: Create a component

A component is a container that connects a repository to Cloudbees Unify.

  1. Select , and then select an organization.

  2. Select Components.

  3. Select Create component.

  4. Select your sample Go app repository from the list.

    • The organization is filled in automatically.

  5. Select Create components to create the component.

  6. Select Finish and close.

Your component appears in the Components list with a repository connection indicator, confirming that Cloudbees Unify can detect your repository and is ready to run automation against it.

If your repository does not appear in the list: Your repository connection may not be complete. Return to Connect your repository and verify that authentication succeeded.

Step 2: Open the Workflow composer

Now that the component exists, we create a workflow inside it. The Workflow composer is where you define what happens when automation runs.

  1. Select your new component from the Components list.

  2. Select the Workflows tab.

  3. Select Create standard workflow.

The Workflow composer opens with a default "hello world" example workflow. Two synchronized views display: a visual representation on the left and a code editor on the right showing the workflow as YAML (a human-readable data format used to define workflows). Changes in one view automatically update the other.

Hello world output workflow
Figure 1. Default workflow which outputs "hello world"

Step 3: Replace the default workflow with a CI job

The default workflow outputs "hello world." Now we replace it with a real CI workflow that builds and tests our Go application.

  1. Select inside the code editor to edit the YAML file.

  2. Delete the default build job (lines 11-17).

  3. Starting on line 11, enter the following:

    ci-job: (1) steps: - name: checkout (2) uses: https://github.com/cloudbees-io/checkout@v2 - name: Build Go app (3) uses: docker://golang:1.22 run: | go build -v ./... - name: Run tests (4) uses: docker://golang:1.22 run: | go test -v ./...
    ▼
    1 The job. ci-job is the name of the job. A workflow can contain one or many jobs.
    2 Checkout. This step uses a Cloudbees action (pre-built, reusable automation) to pull your repository code into the workspace.
    3 Build. This step runs a Go 1.22 container and builds your application.
    4 Test. This step runs the same Go container and executes your test suite. If any test fails, the workflow run fails.

The code editor shows your updated YAML with a ci-job containing three steps. The visual view updates to reflect the new job structure.

If the visual view does not update: Your YAML may contain a syntax error. The code editor on the right underlines the problem line in red. Look for missing indentation, missing colons, or a misspelled keyword.

Step 4: Commit the workflow and trigger a run

Saving a workflow in Cloudbees Unify means committing it to your repository. This commit also triggers the workflow to run for the first time.

  1. Select Commit.

  2. Enter a Commit message, for example, Add CI workflow for Go app.

  3. Select Commit to current branch.

  4. Select FINISH.

The workflow file is committed to your repository in the .cloudbees/workflows directory, and a workflow run starts automatically. If you check your connected GitHub repository, the new commit appears there too.

First commit
Figure 2. Commit in connected GitHub repository

If no run appears within a few seconds: Check the Runs view of your component. If the run shows a red error icon on checkout, your repository connection may need to be refreshed. If no run appears at all, verify that the commit landed on the main branch.

Step 5: Review your results

Your workflow is running. Now we check the results to confirm that the build and tests passed.

  1. Select Components, and then select your component.

  2. Select the Runs tab.

  3. Select your run from the list.

  4. Select JOB LOGS to display the output of each step.

  5. Select Expand all in the upper right to display the details of every step.

Each step shows a green success indicator. You can expand any step to review its logs:

  • Checkout: your repository files being pulled

  • Build Go app: the Go compiler building your application

  • Run tests: your test results with pass/fail output

If a step shows a red error icon: Select the failed step to view the error message, then expand that step’s log and read from the bottom up, as the most recent line usually contains the error.

Step 6: Make it your own

This is the moment that proves the automation works for you, not just for the workflow file you committed. We change a line of code in the app and watch the workflow run automatically.

  1. In your connected GitHub repository, open any source file, for example, main.go.

  2. Select the pencil icon to edit the file.

  3. Add a comment line such as, // My first automated build.

  4. Commit the change directly to the main branch.

  5. Return to the Runs view in Cloudbees Unify.

A new run appears at the top of the Runs list within a few seconds, triggered by your code change. When it finishes, both runs are visible: your first one (the workflow commit) and your second one (the code change).

What we learned

In this tutorial we built a CI pipeline that automatically builds and tests a Go application on every code change. Along the way we created a component for your connected repository, defined a multi-step job in the workflow composer, and confirmed the automation loop: code change, workflow run, result.

These skills apply to any language or framework. You now have a working pipeline and a starting point to build on.

Next steps

Now that we have a working workflow, you can go further: