huserben / TfsExtensions

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

Trigger a build that is using another repository #211

Closed syunwei closed 2 years ago

syunwei commented 2 years ago

Hi Ben,

Thank you so much for developing this extension. I got an error on 'Could not queue the build because there were validation errors or warnings.', think the error is from Azure DevOps. I've tried to trigger another build in another pipeline which is under the same repo, for example, pipeline1 triggers a build in pipeline2 and pipeline yaml files for pipeline1 and pipeline2 are in the same repo. But it has an error when pipeline2's yaml file is from another repo. Please see the following logs:

##[debug]useCustomSourceVersion=false
##[debug]customSourceVersion=undefined
##[debug]useSameBranch=false
##[debug]branchToUse=undefined
##[debug]waitForQueuedBuildsToFinish=true
##[debug]waitForQueuedBuildsToFinishRefreshTime=60
##[debug]failTaskIfBuildsNotSuccessful=true
##[debug]cancelBuildsIfAnyFails=false
##[debug]treatPartiallySucceededBuildAsSuccessful=false
##[debug]downloadBuildArtifacts=false
##[debug]dropDirectory=/home/vsts/work
##[debug]storeInEnvironmentVariable=false
##[debug]demands=undefined
##[debug]queueid=undefined
##[debug]buildParameters=undefined
##[debug]templateParameters=undefined
##[debug]delayBetweenBuilds=0
##[debug]authenticationMethod=Personal Access Token
##[debug]username=undefined
##[debug]password=XXX
##[debug]enableBuildInQueueCondition=false
##[debug]includeCurrentBuildDefinition=true
##[debug]blockingBuildsList=undefined
##[debug]blockInProgressBuilds=false
##[debug]dependentOnSuccessfulBuildCondition=false
##[debug]dependentBuildsList=undefined
##[debug]dependentOnFailedBuildCondition=false
##[debug]dependentFailingBuildsList=undefined
##[debug]checkbuildsoncurrentbranch=false
##[debug]failTaskIfConditionsAreNotFulfilled=false
Using current Team Project
Team Project: XXX
Using current Collection Url
Server URL: https://dev.azure.com/XXX/
Using following Authentication Method: Personal Access Token
Using Personal Access Token
Provided team project was guid.
Context is Build - using Build Environment Variables
Build shall be triggered for same user that triggered current build: XXX
No build definition with name 1087 found...
Specified build name is a number - will treat as build id...
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.
##[debug]task result: Failed
##[error]Request failed after 5 tries - see error messages in the log
##[debug]Processed: ##vso[task.issue type=error;]Request failed after 5 tries - see error messages in the log
##[debug]Processed: ##vso[task.complete result=Failed;]Request failed after 5 tries - see error messages in the log
Finishing: TriggerBuild

pipeline1.yaml:

trigger:
  branches:
    include:
      - master
      - "*"
resources:
  repositories:
    - repository: self
      type: git
      ref: master

variables:
  - name: system.debug
    value: true

stages:
  - stage: test
    jobs:
      - job: 
        steps:
          - task: TriggerBuild@4
            inputs:
              definitionIsInCurrentTeamProject: true
              buildDefinition: '1087'
              queueBuildForUserThatTriggeredBuild: true
              ignoreSslCertificateErrors: false
              useSameSourceVersion: false
              useCustomSourceVersion: false
              useSameBranch: false
              waitForQueuedBuildsToFinish: true
              waitForQueuedBuildsToFinishRefreshTime: '60'
              failTaskIfBuildsNotSuccessful: true
              cancelBuildsIfAnyFails: false
              treatPartiallySucceededBuildAsSuccessful: false
              downloadBuildArtifacts: false
              storeInEnvironmentVariable: false
              authenticationMethod: 'Personal Access Token'
              password: $(mypass)
              enableBuildInQueueCondition: false
              dependentOnSuccessfulBuildCondition: false
              dependentOnFailedBuildCondition: false
              checkbuildsoncurrentbranch: false
              failTaskIfConditionsAreNotFulfilled: false

pipeline2.yml

trigger:
  branches:
    include:
      - master
      - "*"
resources:
  repositories:
    - repository: self
      type: git
      ref: test

stages:
  - stage: Build
    jobs:
      - job: Build
        steps:
          - script: echo "Build..."

Just wanted to confirm this extension is working even if the pipelines are in different repos? and if it's supported could you please check the config above to see what parameter is wrong? Thank you.

syunwei commented 2 years ago

Hi Ben,

I was able to trigger another job in another pipeline by using TriggerBuild extension. The original problem was from Azure DevOps, the DefaultBranch in Azure DevOps was set to master and my pipeline was running from a YAML file from another branch. After setting default branch to my another branch and set useSameBranch to false, the pipeline triggering worked. I thank you very much for developing this extension which saves a lot of developers' time. Is it possible to expose error and warnings from Azure DevOps in order to identify the issue more quickly ? In stead of having an error message like 'Error message: Error: Could not queue the build because there were validation errors or warnings.', the reasons the error/warning will be very helpful for debugging. Thank you again for your time and effort on developing this extension :)

huserben commented 2 years ago

Hi @syunwei

ok that would have been my first suggestion as well. I'm glad you managed to work around your problem.

This error is actually what we get from the API, there is not more to show. So sadly nothing that can be done about that I feel.

As the problem is solved for you I'll close this issue. Thanks for reporting this and updating here on the solution that worked the problem, that way others will also be able to profit from it if they face the same issue.