DevSecOps and Automation on Power

 View Only

Implement Red Hat OpenShift Pipelines as Code with Bitbucket on IBM Power

By Lakshmi Daruri posted Wed May 08, 2024 07:30 AM


Welcome back to our blog series on Red Hat OpenShift Pipelines as Code! In our previous blogs, Red Hat OpenShift Pipelines as Code on IBM Power and Implementing OpenShift Pipelines as Code with GitHub on IBM Power, we introduced you to the captivating world of Pipelines as Code, giving you a glimpse of what is possible and also provided detailed steps to enable Pipelines as Code  and GitHub work together. In this blog, we dive deeper into the partnership between OpenShift Pipelines as Code and Bitbucket, on IBM Power.

Initially, Pipelines as Code was integrated with GitHub, and later extended to Bitbucket and GitLab. In this blog, we focus on implementation of Pipelines as Code with Bitbucket. This can be done by raising a pull request in Bitbucket repository, which triggers the creation of a pipeline run on the OpenShift cluster.

Our next blog on implementation of Pipelines as Code with GitLab will be published soon!

Pipelines as Code is implemented to allow you define your Tekton templates with the pipelinerun.yaml   file, in your source code repository. The pipeline runs and reports the execution status when a pull request or a push is triggered. 

Implementing Pipelines as Code on IBM Power with Bitbucket

Before you are ready to roll, make sure you have a Bitbucket account. If you're not already a part of the Bitbucket community, head over to Bitbucket and follow the simple prompts to create your account.

OpenShift Pipelines as Code with Bitbucket is a continuous integration/continuous delivery (CI/CD) service built into Bitbucket. It allows you to automatically build, test, and deploy code based on a configuration file in the repository. Bitbucket has lower prices and allows free private repositories but has fewer features than GitLab and is less user friendly.

For more information on Pipelines as Code with Bitbucket, see Use Pipelines-as-Code with Bitbucket Cloud.


  • Install the latest version of OpenShift Pipelines Operator
  • Deploy gosmee

For detailed instructions on installing OpenShift Pipelines Operator and deploying gosmee, check out our first blog in the series, Red Hat OpenShift Pipelines as Code on IBM Power.

Perform the following steps to implement Pipelines as Code with Bitbucket:

  1. Create a Bitbucket repository using the Bitbucket UI.
  2. Create a Bitbucket cloud app password.
  3. Clone the Bitbucket repository to your local machine.
  4. Use the tkn pac create repo command to create a Pipelines as Code repository and configure webhook.
  5. Commit your changes and push them to your remote repository.
  6. Raise a pull request or commit your changes to the main branch of your repository.

Now, let’s discuss each of the above steps in detail.

Step 1: Create a Bitbucket repository

The Bitbucket application integrates with OpenShift Pipelines and fetches the Bitbucket workflow into Tekton pipelines.

Bitbucket application's webhook points towards Pipelines as Code Controller route, or the ingress endpoint which would listen to the Bitbucket events.

As explained earlier, the very first step is to create a Bitbucket account. Go to and follow the simple prompts to create one. Log in to your account and perform the following steps to create a repository.

  1. Open the Bitbucket UI and click Create > Repository.
  2. Enter a name for the repository and specify other details as shown in the following screenshot, and click Create repository.
    create repository

Step 2. Create a Bitbucket Cloud app password

App passwords are user-based access tokens for scripting tasks and integrating tools (such as CI/CD tools) with Bitbucket Cloud.

  1. Go to your profile and click Personal settings.
  2. In the ACCESS MANAGEMENT section, click App passwords and then click Create app password.
    create app password
  3. Specify the permissions (as shown in the following screenshot) and then click Create to create a new app password.

    Note down the app password that is created in this step.

Step 3: Clone the Bitbucket repository to your local machine

Clone the Bitbucket repository to your local machine using the following command:

# git clone <repo url>
# cd <repo name>

Step 4: Configure webhook and create a repository

Run the tkn pac create repo command to configure webhook and create the repository. Provide the necessary input when prompted.

# tkn pac create repo
? Enter the Git repository url (default:
? Please enter the name where the pipeline should run (default: PAC-191-412-pipelines): default
✓ Repository lakshmidaruri-PAC-191 has been created in PAC-191 namespace
? 👌 A GitHub App is configured for your cluster, Would you like to setup webhook for your repository? Yes
? Please enter the provider name to setup the webhook: bitbucket-cloud
✓ Setting up Bitbucket Webhook for Repository ? Please enter your bitbucket cloud username:  <Your username>
ℹ ️You now need to create a Bitbucket Cloud app password, please checkout the docs at for the required permissions
? Please enter the Bitbucket Cloud app password:  ************************************
👀 I have detected a controller url:
? Do you want me to use it? Yes
✓ Webhook has been created on repository lakshmidaruri/Pipelines as Code-191-412
🔑 Webhook Secret lakshmidaruri-PAC-191-412 has been created in the default namespace.
🔑 Repository CR lakshmidaruri-PAC-191-412 has been updated with webhook secret in the default namespace
ℹ Directory .tekton has been created.
✓ A basic template has been created in /root/.tekton/pipelinerun.yaml, feel free to customize it.
ℹ You can test your pipeline manually with: tkn-PAC resolve -f .tekton/pipelinerun.yaml | kubectl create -f-


This creates the ’.tekton’ folder, with the pipelinerun.yaml file, which contains the default content to run a pipeline. It creates a Bitbucket repository and a secret in the given names Pipelines as Code on the OpenShift cluster. It also configures the webhook controller URL and secret in the Bitbucket repo for you.

# ls -a
.  ..  .git  .gitignore  .tekton

You can view the OpenShift cluster on the Repositories tab.

repo tab

Step 5: Commit the changes and push the repository

Commit the changes locally and push the repository to the Pipelines branch.

# git add .
# git commit -m”PAC12”
[pipeline 98f780a] ”PAC12”
 1 file changed, 89 insertions(+)
 create mode 100644 .tekton/pipelinerun.yaml
# git checkout -b pipeline
# git push origin pipeline

Step 6: Initiate a pull request / commit to the main branch of the repository

After pushing the repository to the pipeline branch :

  1. Go to the repository and select Pull request from the menu on the left, and click Create pull request.
  2. Select pipeline as the source branch  and  main/master as destination branch and click Create pull request.

    This initializes the pipelinerun.yaml file located in the .tekton folder to run.


    You can see the results in the Bitbucket repo, and view the PipelineRun on the Red Hat OpenShift cluster.

    Bitbucket repo

    When you click any of the tasks of the PipelineRun, you will be redirected to the Red Hat OpenShift cluster, where the pipeline run takes place.

    PipelineRun details

    In this is way, you can easily switch between the Bitbucket repository and the OpenShift cluster to observe the progress of pipelines.


So, this was all about implementing Pipelines as Code with Bitbucket on IBM Power! We hope you are now feeling more confident about using this incredible feature with Bitbucket. Drop us a line about your experience of working on Pipelines as Code with Bitbucket. Stay tuned for the last blog in this series.