Remote Jenkins Build Triggering with Parameter Passing

├Źndice
  1. Introduction
  2. Remote Build Triggering
  3. Parameter Passing
  4. Conclusion

Introduction

Jenkins is an open-source automation server that allows developers to automate various tasks, such as building, testing, and deploying software. One of the most useful features of Jenkins is its ability to trigger builds remotely. In this article, we will discuss how to trigger a remote build in Jenkins and pass parameters to the build.

Remote Build Triggering

To trigger a remote build in Jenkins, you need to have the Jenkins Remote Access API Token. This token can be found in the Jenkins web interface under the user's settings. Once you have the token, you can use it to trigger a build by sending an HTTP POST request to the Jenkins server.

Here is an example of how to trigger a build remotely using the Jenkins API:


curl -X POST -u username:APIToken http://jenkins-server/job/job-name/buildWithParameters?PARAMETER=Value

In the above example, replace "username" with your Jenkins username and "APIToken" with your Jenkins API token. Also, replace "jenkins-server" with the URL of your Jenkins server, "job-name" with the name of the job you want to trigger, and "PARAMETER=Value" with the parameter you want to pass to the build.

Parameter Passing

To pass parameters to a remote build in Jenkins, you need to use the "buildWithParameters" API endpoint. This endpoint allows you to specify parameters to be passed to the build as query string parameters.

Here is an example of how to pass parameters to a remote build using the "buildWithParameters" API endpoint:


curl -X POST -u username:APIToken http://jenkins-server/job/job-name/buildWithParameters?PARAMETER1=Value1&PARAMETER2=Value2

In the above example, replace "username" with your Jenkins username and "APIToken" with your Jenkins API token. Also, replace "jenkins-server" with the URL of your Jenkins server, "job-name" with the name of the job you want to trigger, and "PARAMETER1=Value1&PARAMETER2=Value2" with the parameters you want to pass to the build.

Conclusion

In conclusion, triggering remote builds in Jenkins and passing parameters to those builds is a powerful feature that can greatly simplify your development workflow. By using the Jenkins Remote Access API and the "buildWithParameters" API endpoint, you can trigger builds remotely and pass parameters to those builds with ease.

Click to rate this post!
[Total: 0 Average: 0]

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Go up

Below we inform you of the use we make of the data we collect while browsing our pages. You can change your preferences at any time by accessing the link to the Privacy Area that you will find at the bottom of our main page. More Information