Links

How to set an API call from Jenkins

In this Article we will use the HTTP REQUEST Jenkins plugin to make custom calls for the TestProject API.

First, install the HTTP Request Plugin for Jenkins. If you already have it, you can skip this step.

  1. 1.
    In your Jenkins dashboard, go to Manage Jenkins
2. Go to Manage Plugins.
3. Go to Available and search for HTTP Request
4. Select the plugin and Install Without Restart.

Now we shall create the FreeStyle project for the API call.

  1. 1.
    Back in your Jenkins dashboard, select New Item.
2. Select Freestyle project and give it a name.
3. In this window, you can configure the project to your liking. In this article, we will focus on the API call. Go to build, press Add Build Step, and select HTTP Request.

Now we will create the URL for the request.

  1. 1.
    Go to your TestProject account and click on Integrations -> API
2. If you do not have an API key, click on Create API Key; now, we can copy it for further use in our Jenkins Project.
3. After we have the API Key, we press on API Documentation. This will open the documentation window.
4. In this window, we will click on Authorize and enter our API key.
5. Here, we will select which API call we wish to invoke. For this article we will create a Project Parameter with an API Call.
6. Scroll down to ProjectParameters and select the Create New Project Parameter,
We can see the request method. In this case it will be POST.
Press on Try It out to see the body and parameters of the request.
7. Now, we can see the request body and parameters needed to create a new project parameter. First, we will get the project id, go to your TestProject account, find your project, and select the three dots near it -> Copy Id.
Now that you have the ID, you can do the following:
8. You can press on Execute to see the Request URL OR take the URL from here and fill in the {projectid} with your project id.

Now we will go back to the Jenkins dashboard and fill in the HTTP Request build Step.

After we save the Request, we can now build it whenever we want, and you can build it in your CI pipeline.
After we run the Build we will get the following:
It was a success, and now we can see the new Project Parameter!