gitazure-devopsazure-pipelines

Is the --commitId optional at the `az pipelines run` command?


I am trying to run a pipeline from the command line in powershell and these are the commands used:

$targetBranch = master
$versionTag = "12.1.3456"
az pipelines run --organization "https://dev.azure.com/organization/" --project "ProjectName" --id 1234 --branch=$targetBranch --parameters "baseTag=$versionTag"

But I am getting this error: A value for the 'commitId' parameter must be provided.

Which does not make so much sense because on the az pipelines run documentation says that the commitId is optional, and they even have an example without this parameter:

Example:

az pipelines run --name myGithubname.pipelines-java --branch pipeline --variables var1=100 --output table

Also, this script is called from a pipeline in a different repository so I cannot get the last commit id from a command like git rev-parse HEAD

Is there a way to run the pipeline without the commitId parameter?

Thank you :)


Solution

  • commitId isn't a required parameter. I have tested your script in my pipeline and it works fine, the target pipeline has been triggered without any issue.

    pool:
      vmImage: windows-latest
    
    steps:
    - task: PowerShell@2
      inputs:
        targetType: 'inline'
        script: |
          $versionTag = "12.1.3456"
          az pipelines run --org "https://dev.azure.com/{OrgName}/" --project "{ProjName}" --id 510 --branch "main" --parameters "baseTag=$versionTag"
      env:
        AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
    

    As shown in the screenshot, my target pipeline was triggered by Project Collection Build Service account since I am using System.AccessToken for authentication in Azure DevOps CLI.

    enter image description here