Create a service hook for Jenkins

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

This article describes how to set up a service hook for your Azure DevOps project to trigger a Jenkins build. If you use Jenkins to build your apps, you can store your code in a Git repository and use Jenkins for your continuous integration builds. You can trigger a Jenkins build when you push code to your Git repository or when you check in code to a Team Foundation Version Control (TFVC) repository.

You can build part of your app in Azure Pipelines and part in Jenkins. You can trigger a Jenkins build when your Azure Pipelines build is completed so that you use both systems to build your app.

Azure DevOps doesn't charge for setting up service hooks or integrating with external services, and Jenkins is fully open-source and free to use.

Create a Jenkins service hook

To manage service hooks for an Azure DevOps organization or project, you must have Owner or Project Collection Administrator role in the organization.

Configure Jenkins

  1. If you don't have one, set up a Jenkins server.

  2. If you set up Jenkins on-premises, enable HTTPS.

  3. In your jenkins.xml configuration file, set the hudson.plugins.git.GitStatus.NOTIFY_COMMIT_ACCESS_CONTROL system property to disabled by adding or updating the following line in the <arguments> tag, before the -jar parameter:

    -Dhudson.plugins.git.GitStatus.NOTIFY_COMMIT_ACCESS_CONTROL=disabled.

Set up a Jenkins build

  1. In Jenkins, create a new item.

    Screenshot showing New item link in Jenkins.

  2. Select the type of build that's appropriate for your project.

    Screenshot showing Build name and type in Jenkins.

  3. Enter the URL for your Git repository.

    Screenshot showing Source code management settings in Jenkins with Git selected.

Set up the Jenkins service hook

  1. In your Azure DevOps project, go to Project settings > Service hooks at https://<organization-name>/<project-name>/_settings/serviceHooks.

    Screenshot of the Service hooks choice in Project settings.

  2. On the Service Hooks page, select the + icon or Create subscription.

    Screenshot of selecting Create subscription on the Service Hooks page.

  3. On the Service screen, select Jenkins, and then select Next.

    Screenshot of selecting Jenkins on the Service page.

  4. On the Trigger screen, select and configure the Azure DevOps event you want to trigger a Jenkins build, and then select Next.

    Screenshot of selecting and configuring the trigger event.

  5. On the Action screen, configure the Jenkins action to take when the event occurs.

  6. Select Test to test the service hook, and Finish to finish the configuration.

Now when the event occurs in the Git repository, it triggers a Jenkins build.

Tip

You can also create a service hook subscription programmatically with REST APIs. For more information, see Create a service hook subscription programmatically.