huserben / TfsExtensions

Extensions for TFS 2015+ such as custom Widgets (require TFS 2017) and Build Tasks
MIT License
44 stars 22 forks source link

Error: Could not queue the build #252

Closed Shivanky-ms closed 4 months ago

Shivanky-ms commented 5 months ago

We have a pipeline where we are using template parameters in complex json format (object type) with default values When we are running the pipeline from another pipeline using this task

    - task: TriggerBuild@4
      displayName: 'Trigger xyz Pipeline'
      inputs:
        buildDefinition: 'xyz pipeline'
        useSameBranch: false
        branchToUse: 'master'
        storeInEnvironmentVariable: true
        authenticationMethod: 'OAuth Token'
        password: abc
        failTaskIfBuildsNotSuccessful: true
        cancelBuildsIfAnyFails: true

We are getting below error:

    Provided team project was guid.
    Context is Build - using Build Environment Variables
    Build shall be triggered for same user that triggered current build: Shivanky Goyal
    Error during request (1/5)
    Error message: Error: Could not queue the build because there were validation errors or warnings.
    Will wait 1 seconds before retrying request...
    Error during request (2/5)
    Error message: Error: Could not queue the build because there were validation errors or warnings.
    Will wait 2 seconds before retrying request...
    Error during request (3/5)
    Error message: Error: Could not queue the build because there were validation errors or warnings.
    Will wait 4 seconds before retrying request...
    Error during request (4/5)
    Error message: Error: Could not queue the build because there were validation errors or warnings.
    Will wait 8 seconds before retrying request...
    Error during request (5/5)
    Error message: Error: Could not queue the build because there were validation errors or warnings. 

We don't want to pass 'templateParameters' from this pipeline, because we want to pick parameters that are set as default, how can we do that?

huserben commented 5 months ago

Hi @Shivanky-ms

I just tried to reproduce your scenario. I'm using the pipeline below, and it worked fine without specifying a new value, it used the default.

Is the task you shared complete or are there more configuration options? Was the task ever running for you? In this or other configurations?

I'd need more context or input to be able to support you.

parameters:
- name: myString
  type: string
  default: a string
- name: myMultiString
  type: string
  default: default
  values:
  - default
  - ubuntu
- name: myNumber
  type: number
  default: 2
  values:
  - 1
  - 2
  - 4
  - 8
  - 16
- name: myBoolean
  type: boolean
  default: true
- name: myObject
  type: object
  default:
    foo: FOO
    bar: BAR
    things:
    - one
    - two
    - three
    nested:
      one: apple
      two: pear
      count: 3

trigger: none

pool:
  vmImage: ubuntu-latest

jobs: 
- job: whatever
  steps:
    - script: echo myString - ${{parameters.myString}}

    - script: echo myMultiString - ${{parameters.myMultiString}}

    - script: echo myNumber - ${{parameters.myNumber}}

    - script: echo myBoolean - ${{parameters.myBoolean}}

    - script: |
        echo "Foo: ${{ parameters.myObject.foo }}"
        echo "Bar: ${{ parameters.myObject.bar }}"
        echo "Things: ${{ join(parameters.myObject.things, ', ') }}"
        echo "Nested One: ${{ parameters.myObject.nested.one }}"
        echo "Nested Two: ${{ parameters.myObject.nested.two }}"
        echo "Nested Count: ${{ parameters.myObject.nested.count }}"
Shivanky-ms commented 5 months ago

When we are running this pipeline with parameters from another pipeline with task TriggerBuild@4 without passing any parameters, it is not picking default parameters.

huserben commented 5 months ago

Hi @Shivanky-ms

yes, this I got. But as mentioned, I'd need some context, as when I try it, I don't get any errors:

Is the task you shared complete or are there more configuration options? Was the task ever running for you? In this or other configurations?

When you say it's not picking the default parameters, does it mean the pipeline runs, but not with the default ones? Because in the initial issue, you posted an error message where I assumed the pipeline wasn't running at all. How does it exactly behave? If it triggers the pipeline, what parameters is it running with if not the default?

I'd love to support you, but for that I'd need more information.

Shivanky-ms commented 5 months ago

Thanks @huserben, Yes pipeline with parameters is not running at all and pipeline with task TriggerBuild@4 failed with below error: Provided team project was guid. Context is Build - using Build Environment Variables Build shall be triggered for same user that triggered current build: Shivanky Goyal Error during request (1/5) Error message: Error: Could not queue the build because there were validation errors or warnings. Will wait 1 seconds before retrying request... Error during request (2/5) Error message: Error: Could not queue the build because there were validation errors or warnings. Will wait 2 seconds before retrying request... Error during request (3/5) Error message: Error: Could not queue the build because there were validation errors or warnings. Will wait 4 seconds before retrying request... Error during request (4/5) Error message: Error: Could not queue the build because there were validation errors or warnings. Will wait 8 seconds before retrying request... Error during request (5/5) Error message: Error: Could not queue the build because there were validation errors or warnings.

huserben commented 5 months ago

@Shivanky-ms can you share the complete yaml of the task you're using as well as the header with the template parameters of the pipeline you are triggering?

Also is the pipeline in the same organization, and if yes, within the same team project? Lastly, which version are you using? Azure DevOps or Azure DevOps Server? If Server, which exact version is in use?

Shivanky-ms commented 4 months ago

Pipeline1.yaml:

trigger: none

parameters:
  -name: timeout
    type: number
    default: 1

  -name: level1Timeout
    type: number
    default: 2

  -name: level2Timeout
    type: number
    default: 3

  -name: "test"
    type: object
    default:
      -parentTest: a
        areas:
          -component: c
            initial: 'abc@gmail.com'
            level1: 'abc@gmail.com'
            level2: 'abc@gmail.com'

      -parentTest: b
        areas:
          -component: d
            initial: |
              abc@gmail.com
              def@gmail.com
            level1: |
              abc@gmail.com
            level2: 'abc@gmail.com'
          -component: e
            initial: 'abc@gmail.com'
            level1: 'abc@gmail.com'
            level2: 'abc@gmail.com'

stages:
  -${{ each comp in parameters.test }}:
      -stage: ${{ comp.parentTest }}
        displayName: ${{ comp.parentTest }}
        dependsOn:
        jobs:
          -job:
            displayName: ${{ comp.parentTest }}
            pool:
              name: pool-test
              vmimage: 'ubuntu'
            steps:
              -script: echo ${{ comp.parentTest }}
      -${{ each area in comp.areas }}:
          -template: ./templates/testTemplate.yaml
            parameters:
              parentTest: ${{ comp.parentTest }}
              component: ${{ area.component }}
              initial: ${{ area.initial }}
              level1: |
                ${{ area.initial }}
                ${{ area.level1 }}
              level2: |
                ${{ area.initial }}
                ${{ area.level1 }}
              timeout: ${{ parameters.timeout }}
              level1Timeout: ${{ parameters.level1Timeout }}
              level2Timeout: ${{ parameters.level2Timeout }}

Pipeline2.yaml:

    -task: TriggerBuild@3
      displayName: 'Trigger Pipeline1'
      inputs:
        buildDefinition: 'Pipeline1'
        useSameBranch: false
        branchToUse: 'main'
        storeInEnvironmentVariable: true
        authenticationMethod: 'OAuth Token'
        password: pwd
        failTaskIfBuildsNotSuccessful: true
        cancelBuildsIfAnyFails: true

When we run Pipeline2, we get above mentioned error. Our requirement is Pipeline2 should run Pipeline1 with default parameters.

huserben commented 4 months ago

@Shivanky-ms I see you use trigger build version 3, please use the latest one (v4) and retry. That would explain why it doesn't work for you but it works in my test env.

Shivanky-ms commented 4 months ago

Received same error with version 4

huserben commented 4 months ago

Ok thanks for adjusting. The only other thing that sticks out is the "useSameSourceBranch" setting. Can you once try with the setting set to "true" instead and see if that helps? Just to narrow down on what the problem might be.

Shivanky-ms commented 4 months ago

Thanks @huserben , it is working fine with useSameSourceBranch: true Our requirement is to use some other branch, can you please help with resolution for useSameSourceBranch: false?

huserben commented 4 months ago

Thanks for checking. That basically means that the value you provided was not correct.

I can see it's setup like this: branchToUse: 'main'

Does a branch named "main" exist? Because the API gives us a validation error and that means it's not finding that branch. If you are certain that main (written exactly like this) exists, you could also try "refs/heads/main" as an alternative.

Shivanky-ms commented 4 months ago

Thanks a lot @huserben , this was the issue, we are using branch name in which pipeline2.yaml does not exists. We can mark this issue as resolved.

huserben commented 4 months ago

Great @Shivanky-ms , will close the issue then