Unleashing the Power of CI/CD Testing with Bitbucket

Dec 18, 2024
read
Bruno Lopes
Product Leader
Testkube
Read more from
Bruno Lopes
Bruno Lopes
Product Leader
Testkube
By integrating Bitbucket Pipelines and Testkube, you can utilize test automation and make sure that every change to the code is tested before it goes live, making things faster and more reliable.

Table of Contents

Try Testkube instantly. No setup needed. Experience our interactive demo environment in seconds.

Try Testkube instantly. No setup needed. Experience our interactive demo environment in seconds.

Subscribe to our monthly newsletter to stay up to date with all-things Testkube.

You have successfully subscribed to the Testkube newsletter.
You have successfully subscribed to the Testkube newsletter.
Oops! Something went wrong while submitting the form.
Dec 18, 2024
read
Bruno Lopes
Product Leader
Testkube
Read more from
Bruno Lopes
Bruno Lopes
Product Leader
Testkube
By integrating Bitbucket Pipelines and Testkube, you can utilize test automation and make sure that every change to the code is tested before it goes live, making things faster and more reliable.

Table of Contents

Bitbucket + Testkube Integration TL;DR

TL;DR

Bitbucket Pipelines + Testkube Integration

  • 1
    Automated K8s Testing: Integrate Bitbucket Pipelines with Testkube to automatically deploy and run tests in Kubernetes clusters whenever code changes are pushed or pull requests are created
  • 2
    Simple Setup Process: Create a YAML test workflow (like k6 performance tests), configure a bitbucket-pipelines.yml file, and store your Testkube API credentials as Bitbucket variables for secure access
  • 3
    Seamless CI/CD Integration: The pipeline automatically connects to your Kubernetes cluster, deploys test workflows from your repo, and executes them using the Testkube CLI without manual intervention
  • 4
    Enhanced Code Quality: Every code change triggers automated testing, catching bugs early and ensuring only thoroughly tested code reaches production environments
  • 5
    Comprehensive Monitoring: Track test execution progress, view detailed logs, and collect artifacts through both the Testkube dashboard and Bitbucket's pipeline interface for complete visibility

Various CI/CD tools can facilitate continuous deployment, and Bitbucket is one of them. Combined with Testkube, it offers the ideal way to automate and improve your testing processes.

In this blog post, we'll take a look at how to use Bitbucket Pipelines and Testkube to continuously deploy test cases in the Kubernetes cluster environments as part of the CI/CD pipeline.

What is Bitbucket?

Bitbucket is a code hosting and collaboration tool based on Git that assists development teams in efficiently building, testing, and deploying software. It includes powerful features such as Bitbucket Pipelines, an integrated CI/CD service allowing automated builds, testing, and deployments from within your repositories. Bitbucket simplifies the development lifecycle with its robust integration capabilities and seamless workflow management, making it an ideal choice for teams implementing DevOps practices.

By integrating Bitbucket Pipelines and Testkube, you can utilize test automation and make sure that every change to the code is tested before it goes live, making things faster and more reliable.

Benefits of Using Testkube with CI/CD Pipelines 

The integration of Bitbucket Pipelines and Testkube offers several benefits. Below are listed a few benefits:

  • Automated Testing: Run the tests automatically on every push, lowering the risk of any error.
  • Seamless Integration: Improve the CI/CD workflow by seamlessly integrating the Testkube and Bitbucket pipelines.
  • Improved Code Quality: This integration makes it feasible to identify bugs beforehand, which substantially enhances the quality of the code.
  • Enhanced Security: Testkube ensures that your tests run securely by preventing unnecessary exposure in the CI/CD pipeline, which improves overall system security.

Read more about the benefits of using a tool like Testkube to run your tests from your CI/CD pipeline in the Stop Running Tests with your CI/CD article.

Let’s now understand how to integrate Bitbucket Pipelines with Testkube for a reliable and smooth testing process.

Integrating Bitbucket Pipelines with Testkube

Testkube's integration with any CI/CD tool aims to make the testing process more seamless and efficient. Below is a high-level overview of the actions that we’ll perform:

  • Create a repo with a test workflow file. In this case, we’ll use the k6 test workflow.
  • Configure a pipeline with this repo and trigger it when any new pull request is created.
  • Add our Testkube target cluster’s configuration values in this pipeline.
  • The pipeline then deploys the k6 test to our configured Kubernetes cluster and executes it. 

Prerequisites

Once the prerequisites are met, you should be able to launch a target Kubernetes cluster with a Testkube agent setup and configure a Bitbucket pipeline to deploy and run a k6 test workflow on the target cluster.

To create the API token, refer to our API Token document. To find the Org ID and environment IDs, log in to your Testkube Dashboard and select Settings from the menu bar.

In addition, these IDs and tokens must be stored as variables in Bitbucket to ensure their safe access and use during pipeline execution. For more information, refer to the documentation on Bitbucket variables and secrets

Creating a Test Workflow in Testkube

Testkube Test Workflows are an easy and quick way to define and run tests within a Kubernetes cluster. These YAML-based specifications enable the test to be defined in a single file containing the test, images, artifacts, and resource parameters.

It allows you to create multi-step test workflows that thoroughly manage end-to-end requirements while offering you more freedom and control over the tests.

Discover and learn more about Test Workflows, which enable you to perform efficient and seamless testing in Kubernetes frameworks.

The first step is to create a test workflow. Here's how you can create a test workflow using an example:

  • Login to your Testkube dashboard and navigate to the Test Workflow section.
  • Click the "Add New Test Workflow" button. 
  • A "Create a Test Workflow" dialog box appears, and you can build the sample workflow by selecting the "Start from an Example" option.

Here's a sample Test Workflow I created for k6:

We’ll save this k6 test workflow configuration as a YAML file in our Bitbucket repository and configure a Bitbucket pipeline.

Configuring Bitbucket Pipelines

Log in to your Bitbucket account and create a repository containing the test workflow file.

Once your repo has been created, go to Repository Settings and enable Pipelines. It will generate a sample bitbucket-pipelines.yml file with some basic configuration. 

We’ll go ahead and configure the pipeline to trigger whenever a new PR is created. 

The file should contain the pipeline configuration, which includes the image to be used, the build steps, and any necessary environment variables or custom configurations.
Let’s look at a bitbucket-pipelines.yml file.

The workflow described above performs the following actions:

  • Sets up a job to connect to the Testkube cloud using the Testkube API key, organization, and environment ID.
  • Creates and runs the k6 test workflow named testworkflow-actions.
  • testkube version: Checks whether the Testkube CLI is properly installed.
  • Runs the test workflow

Note: The --update flag in the run test workflow command ensures that the test workflow is updated with the latest changes and execution history is preserved

Triggering Testkube Test

Make changes to the bitbucket-pipelines.yml file in the repository, and commit the changes by raising a pull request to trigger the pipeline.

Once the pipeline is triggered, Bitbucket Pipelines will execute the test steps specified in the configuration file.

On the Bitbucket interface, click the Pipelines option to view your pipeline's status, detailed information about the log generated during its execution, and other relevant information.

Based on the configuration, we can see that the pipeline triggers with every new PR; it connects to our target Kubernetes cluster, deploys the k6 test from the repo, and executes the test. 

Monitoring the Test Workflow

You can monitor the workflow’s progress and report in the Testkube dashboard or using the Testkube CLI. Let's see how to check the status of the Test Workflow using the dashboard.

  1. Navigate to the Test Workflows tab, where you will see the k6 test workflow named testworkflow-actions that was deployed using the pipeline.
  1. To know more about the status of the test workflow, click on a step.

After the execution, Testkube collects all artifacts, including a stats report with all outputs and results.

The above example demonstrates how simple configuring Testkube with Bitbucket Pipelines is. One can execute advanced scenarios by modifying the workflow and configuring repositories according to their specific requirements.

Summary

We have learned how to set up the Testkube testing workflow with Bitbucket pipelines and how it enhances our testing experience. By integrating the automation capabilities of Bitbucket Pipelines with the testing capabilities of Testkube, you have not only automated the testing process but also created a robust testing framework for the development pipeline. Additionally, this integration not only allows a seamless and efficient testing process but also ensures consistency and reliability in the CI/CD workflows.

So, what are you waiting for? Go one step further and use the collective power of these two to scale your testing processes and deliver reliable releases more quickly. 

Discover how Testkube can transform your testing strategy. oin our Slack community to start a conversation or read Testkube documentation to see how Testkube can enhance your GitOps testing workflow, ensuring seamless, efficient, and automated testing within the Kubernetes environments. The future of software testing is here. Are you ready to be a part of it?

In today's fast-paced world of software development, every build and new feature must be thoroughly tested to ensure a seamless experience and an efficient delivery. Continuous testing enables teams to automate test execution at all stages, detecting issues early and confidently delivering reliable updates. Integrating testing with your CI/CD tools ensures that every code submission triggers the necessary tests, accelerating development while allowing you to focus on other vital tasks.

Tags
No items found.

About Testkube

Testkube is a cloud-native continuous testing platform for Kubernetes. It runs tests directly in your clusters, works with any CI/CD system, and supports every testing tool your team uses. By removing CI/CD bottlenecks, Testkube helps teams ship faster with confidence.
Explore the sandbox to see Testkube in action.