Skip to content

Deploying CI/CD Pipeline

Workflow

ci-workflow

Pre-requisites

Set-up everything from Deploying Delivery Pipeline but don't run the last step i.e create pipeline run. We will be using triggers for automation now.

Create WebHook Secrets

Provide GithubToken created in section 1.1 as a base64 encoded string:

vi webhooks/secrets/webhook-secret.yaml

Create secret:

kubectl apply -f webhooks/secrets/webhook-secret.yaml -n <NAMESPACE_NAME>

Create Webhooks

Update Namespace value for unique webhooks:

# replace the <NAMESPACE_NAME> with your namespace
sed -i "s/NAMESPACE_NAME/<NAMESPACE_NAME>/g" webhooks/taskrun-webhook.yaml

Update Username value for creating a webhook in your forked repo:

# replace the <USERNAME> with your namespace
sed -i "s/USERNAME/<USERNAME>/g" webhooks/taskrun-webhook.yaml

Create Webhooks so that the pipelines get triggered on new PRs:

kubectl apply -f webhooks/. -n <NAMESPACE_NAME>

Create Triggers

Update Namespace and Username value according to your own namespace:

# replace the <NAMESPACE_NAME> field with your namespace
sed -i "s/NAMESPACE_NAME/<NAMESPACE_NAME>/g" triggers/trigger.yaml
# replace the <USERNAME> field with your username
sed -i "s/USERNAME/<USERNAME>/g" triggers/trigger.yaml

Create trigger resources:

kubectl apply -f triggers/trigger.yaml -n <NAMESPACE_NAME>

Test Route

Verify EventListener Route created in your namespace

On OpenShift Dashboard, On the left panel, Go to Networking -> Routes and verify an event listener route is created.

Verify by Opening the URL under Location and verify the response is similar to this:

{"eventListener":"inventory-eventlistener","namespace":"<NAMESPACE>","eventID":"cx8n4"}

CI - Create A PR in the Forked Repository

Now attempt to make a PR in your forked repository. which will trigger an automated build.

Create a PR and verify its status

  • Create a PR for the forked repo by adding a test_file.txt with some random text in a branch test-branch

  • As soon as the PR is created Pipeline will be triggered which can be seen in OpenShift dashboard under Pipeline -> Pipeline Runs

  • On successful build, the status would be shown as follows

Pipeline Status

  • A comment will be posted on the PR on GitHub to reflect the status of the Pipeline

PR Status

CD - Merge this PR into the main

Now attempt to merge this PR in main

Merge PR in main

  • Merge the Pull Request in the main to rigger the pipeline on main branch

main status

  • After successful execution a new release and tag will be created in the Releases section on GitHub

new release

Verify new Image

Verify that the new image is available in your registry

Verify new Tags

Verify forked repository to new newly pushed tag

Forked Repository

Copyright © 2023 Stakater AB – Change cookie settings