DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Building Micro-Frontends With Vue and Reusable Components
  • Build an AI Chatroom With ChatGPT and ZK by Asking It How!
  • Build Your Own AI Avatar App From Scratch in Less Than 8 Hours
  • 10 Best Practices to Launch APIs in 2023

Trending

  • Contextual AI Integration for Agile Product Teams
  • Unlocking the Benefits of a Private API in AWS API Gateway
  • Docker Base Images Demystified: A Practical Guide
  • AI Meets Vector Databases: Redefining Data Retrieval in the Age of Intelligence
  1. DZone
  2. Data Engineering
  3. Databases
  4. Triggering Jenkins Build Remotely Using API

Triggering Jenkins Build Remotely Using API

Any Jenkins Job can be triggered remotely through an API call. This article outlines how to do exactly that in just four easy steps.

By 
Shantha Priya user avatar
Shantha Priya
·
Apr. 10, 21 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
28.5K Views

Join the DZone community and get the full member experience.

Join For Free

Any Jenkins Job can be triggered remotely through an API call.

We can extract the API output either in XML(SOAP) or in JSON(REST) format.

STEP 1: Get the Authorization Token

1.Click on the Configure option under your username

2.Under API token Click on the Show Legacy API Token. See images below.

 


 

3.Copy the token and use it in the place of a password

STEP 2: Trigger the Build

API: https://JENKINS_URL/job_path/buildwithParemters?

Method: POST

Parameters: Username= “username” 

Password= “Token”

OUTPUT: 

Return the header with the queue number of the job.

The above two steps are used to trigger a Jenkins Parameterized build remotely. In order to get the status of the build, you must follow the three steps below. Jenkins build, once triggered, will have the below flow:

Job Triggered->Waits on Queue(Queue Number)->assign node for the build -> gets a Build Number

STEP 3: Get the Build Number

Pass the Location URL from the previous API output header to get the Build Number.

API: Locationurl/api/json?

 Eg: https://jenkins.xxx.com/jenkins/queue/item/1691997/api/json

Method: GET 

Parameters: Username= “username”

Password= “Token”

OUTPUT:

Returns the Build Number and the URL of the job

STEP 4: Get the Build Status

Pass the Build URL from the previous API output to get the Build Status.

API: BuildUrl/api/json?

  Eg: https://jenkins.test.com/jenkins/job/test/job/access/63/api/json

Method: GET 

Parameters: Username= “username”

Password= “Token”

OUTPUT:

Returns the Build Status of the job.

 

API Build (game engine) Jenkins (software)

Opinions expressed by DZone contributors are their own.

Related

  • Building Micro-Frontends With Vue and Reusable Components
  • Build an AI Chatroom With ChatGPT and ZK by Asking It How!
  • Build Your Own AI Avatar App From Scratch in Less Than 8 Hours
  • 10 Best Practices to Launch APIs in 2023

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!