Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

CI/CD For API Development [WSO2 API Manager 2.6.0]

DZone 's Guide to

CI/CD For API Development [WSO2 API Manager 2.6.0]

Lean how to use the plugin in your Maven Based projects to achieve the CI/CD.

· Integration Zone ·
Free Resource

Introduction 

WSO2 API Manager is a complete platform for lifecycle management of APIs. Although the API Manager comes with a built-in module to publish APIs, it's not possible to apply CI/CD. To compensate this the API Manager provides a set of useful REST APIs and by using these APIs a CI/CD pipeline can be built easily.

Maven Plugin 

I have created a Maven Plugin using the exposed REST APIs and in this article, I will be showing how to use the plugin in your Maven Based projects to achieve the CI/CD. Please feel free to download/clone the plugin and modify it according to your needs.

Prerequisites 

The plugin is created using the REST APIs exposed by WSO2 API Manager 2.6.0. So, to execute the CI/CD demo in the below section, you must have WSO2 API Manager 2.6.0 up and running.

Scenario 

We are implementing an API in a Java project (Maven based). When the implementation is done, we push the code to the Github. We define a pipeline in Jenkins server where we configure our Maven plugin to execute. On successful execution of the plugin, the API of our project (swagger.yaml) is published in the WSO2 API Manager (2.6.0). 

Create a Simple Project

The complete source code of the API implementing project i.e blog-api can be found here.

project

Here is a snapshot of the pom.xml:

Image title

Note that in the pluginRepository I am pointing it to a public bitbucket repository for this demo. Feel free to clone/download the Plugin and install in your local repository. The plugin configuration is quite straightforward. 

Jenkins Configuration

Download Jenkins and run it. Download the Maven Integration plugin and then configure it under 

Jenkins -> Global Tool Configuration.

Image title

Create a Pipeline Project

Click New Item and create a Pipeline project.

Image title

Set the Build Trigger to every minute as shown below,

Image title

Here is a simple three staged pipeline definition.

Image title

Check details of how to use the Maven Plugin in the plugin documentation.

Execution

Commit and push changes of the blog-api project to Github. The Jenkins is polling on the GitHub repository every minute and the pipeline will be executed automatically. After successful execution of the pipeline, the API configured in the plugin will be published in the API Manager. (Make sure that the API Manager is running)

Conclusion

In this article, I have shown how easily the REST APIs of the WSO2 API Manager can be used to build a CI/CD pipeline. The plugin is very simple (for demo purpose), but feel free to make changes to it to adapt to your requirements.

Topics:
wso2 api manager ,integration tutorial ,integration ,api development ,ci/cd ,api manager

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}