SearchStax APIs for CI/CD On BitBucket Pipeline

SearchStax APIs for CI/CD On BitBucket Pipeline

SearchStax APIs can be leveraged for CI/CD or Continuous Integration and Continuous Delivery to help Devops teams implement and deliver code changes in an automated manner. 

With the SearchStax fully-managed Solr-as-a-Service solution, we include an extensive set of APIs that give development teams the resources they need to seamlessly integrate Solr into their applications, tools and systems. This post provides a quick introduction to CI/CD and offers a simple example for how to leverage the SearchStax APIs for CI/CD on the BitBucket pipeline to automatically push config changes to a Solr cluster.

What is CI/CD?

CI/CD is an application development best practice that combines an agile culture, a set of operating principles and a collection of practices that enable teams to deliver application code changes frequently and more reliably. This implementation approach, also known as the CI/CD pipeline, allows teams to spend more time focused on meeting business requirements, code quality and security because the deployment steps have been automated.

In a world of spread-out development teams, it is more important than ever to have proper tools to be able to work together and to deliver work in the most efficient way possible. With consistency in the application integration process, teams using CI/CD pipeline are able to commit code changes more frequently leading to better collaboration and software quality.

In a simple use case, SearchStax APIs can be used to set up a configuration update pipeline where Solr configs are updated any time a change is made in the repository. For more complex use cases, such as a Blue-Green deployment (which we discussed in an earlier blog post), a software release can be achieved to create a replica of the primary deployment environment, push changes to the replica, then backup, restore and switch the replica to production. 

Getting Started with SearchStax APIs for CI/CD on BitBucket Pipeline

To demonstrate how to use the SearchStax APIs. we take a look at a simple example to build a pipeline where config changes are pushed automatically to the Solr cluster. The instructions in this example are based on the BitBucket Pipeline, but the same instructions would apply to other CI/CD pipelines as well, including GitHub Actions.

A Solr config can be uploaded from a repository by:

  1. Creating an archive of the Solr config.
  2. Uploading/Replacing the config in Solr.
  3. Reloading the Solr collections that use the above config.

We have translated the above steps into a python script that can be placed in the repository and executed via the BitBucket pipeline.

Creating an Archive

An archive can be created using any number of libraries. In this example, we have used the “zipfile” library.

SearchStax APIs for CI/CD On BitBucket Pipeline - Create an Archive

Uploading/Replacing the Solr Config

Zookeeper Read API by SearchStax will let us check if the config already exists. If it does, then Zookeeper Delete API by SearchStax will help us delete the config.

SearchStax APIs for CI/CD On BitBucket Pipeline - Upload Solr Config

After this, we can use Zookeeper Upload API by SearchStax to upload the new Solr config.

Upload Solr Config 2

Reloading the Solr Collections

After updating the Solr config, we should reload all the collections that are using the updated config so that the changes to the configs are picked up by the Solr collections. This example uses CLUSTERSTATUS API and RELOAD API from Solr to reload the collections.

SearchStax APIs for CI/CD On BitBucket Pipeline - Reload Solr Config

Executing the Config Steps in BitBucket Pipeline

We can compile the modules into a single script that’s placed in a repository and can be called in a BitBucket Pipeline directly.

Execute Config Steps

Learn More About SearchStax APIs for CI/CD

This quick example demonstrates how easy it is to use SearchStax APIs for CI/CD on the BitBucket pipeline. 

You can learn more about the SearchStax API in our online product documentation and see how they can help your developers realize their vision for an ideal CI/CD pipeline.