4
votes

We use Jenkins as our build orchestrator, and are just spiking the use of Azure DevOps for a particular project. Our build works fine, pulling code from Git and creating the artifacts we need, whether we trigger automatically from git or manually.

I still want Jenkins to be the orchestrator however, so that our pipeline is more obvious to people not in our team.

There is a lot of info about triggering Jenkins from DevOps, but I haven't found anything to support what we need. Is it possible, and can you share any examples please?

2

2 Answers

5
votes

You can trigger a build in Azure DevOps using its REST API. The API for triggering build is documented here.

Basically it's a POST operation to the following endpoint:

POST https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=5.0

And authentication can be done using OAuth or Personal Access Token as documented here.

Depending on your technology of choice, there may also be a client object model you can use.

A powershell sample can be found here.

1
votes

This can be done natively using Azure Pipeline Releases.

  1. Create a Service Connection between Azure DevOps and your Jenkins Server
  2. Create a new Release Pipeline in the Releases tab under the Pipelines section in Azure Devops
  3. Add an artifact to the release pipeline (on the left hand side). In the view that appears choose '4 more artifact sources' and Jenkins will appear.
  4. Choose the Service Connection you created from the drop for the Jenkins connection then choose the Jenkins Job from the next drop down.

This makes is clearer for your devs to see what's going on. Whilst using rest is a good method it hides a lot of the work. This way anyone looking at the front page of a release can see the artifact sources.

HTH