Learn how to call the Jenkins REST API from PowerShell
Blog post from Octopus Deploy
In a blog post by Matthew Casperson, the process of triggering Jenkins builds using Octopus is explored, highlighting a method to initiate Jenkins deployments via its REST API and PowerShell. Jenkins employs a Cross Site Request Forgery (CSRF) protection mechanism, necessitating the inclusion of a "crumb" in each API request header. Casperson provides a PowerShell script to generate this crumb by making a request to the Jenkins crumb issuer endpoint. With the crumb in hand, users can programmatically trigger Jenkins builds by sending a POST request to a specific URL associated with the Jenkins job, which is demonstrated in the provided PowerShell script. The successful execution of the script is confirmed by an HTTP 201 status code, indicating that the job was created on the Jenkins server.