-1

I have two project1 and project2 hosted on jenkins and azure devops respectively.

  1. Jenkins => project1
  2. Azure Deveops =>project2

My requirement is when user trigger project1 build from jenkins manually once project1 build succeed at the same time automatically trigger project2 build which is hosted on azure.

So that end user can test both projects on there environments.

ND's
  • 2,155
  • 6
  • 38
  • 59

1 Answers1

1

Based on your description, you may consider using WebHook to trigger the pipeline in Azure DevOps.

  1. Add a command like below to post WebHook payload from your Project 1 in Jenkins to the URL;

    $URL = "https://dev.azure.com/<TheDevOpsOrgName>/_apis/public/distributedtask/webhooks/<WebHookName>?api-version=6.0-preview"
    $header = @{
    
        'Content-Type' = 'application/json'
    }
    $Payload = @"
      {
        "parameter_from_Jenkins": "Jenkins webhook trigger",
        "parameter_name": "test"
      }
    "@
    Invoke-RestMethod -Method Post -Uri $URL -Headers $header -Body $Payload | ConvertTo-Json
    
    
  2. Create an incoming WebHook service connection like below; Incoming WebHook Service Connection

  3. Add a WebHook resource into the YAML pipeline;

    trigger: none
    pool:
      vmImage: windows-latest
    resources:
      webhooks:
      - webhook: WebHookName ### Webhook alias
        connection: WebHookSvcCnn ### Incoming webhook service connection
    steps:
      - task: PowerShell@2
        inputs:
          targetType: 'inline'
          script: 'Write-Host This pipeline run is triggered by ${{ parameters.WebHookName.parameter_from_Jenkins }}'
    
  4. Once the request is sent, the WebHook service connection will listen the incoming request and trigger the pipeline in DevOps. Pipeline run triggered by WebHook

Alvin Zhao-MSFT
  • 508
  • 2
  • 6
  • Where to ADD step1 in jenkins? Trying to add inside Build=>Execute Windows batch Command – ND's Aug 30 '22 at 13:57