huserben / TfsExtensions

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

Trouble using Build Parameters in triggered pipeline #182

Closed Hoyzer90 closed 3 years ago

Hoyzer90 commented 3 years ago

Hi I'm trying to use the BuildParameters to pass a test suite name from PipelineA to B, PipelineA trigger:

      task: TriggerBuild@3
      displayName: 'Trigger e2e test run'
      inputs:
        buildDefinition: 'app-e2e'
        useSameBranch: false
        branchToUse: UserStory/US12345
        waitForQueuedBuildsToFinish: true
        authenticationMethod: OAuth Token
        password: $(System.AccessToken)
        buildParameters: 'TestSuite: APP-API'```

This is part of the second pipeline where I'm trying to use the parameter

task: SoapUIProForAzureDevOpsTask@1
  displayName: 'SoapUI Pro for Azure DevOps'
  inputs:
    project: 'API-ReadyAPI'
    testSuite: $(TestSuite)

I can use $(TestSuite) to get the property thats passed between pipelines but then the problem is if I want to run the pipelineB on its own the testSuite input is set to "$(TestSuite)" instead of empty which causes it to not run any tests, if I use ${{TestSuite}} then when I run the e2e on its own it runs the full project as I want but when run as part of pipelineA its not set so it runs all tests instead of just the testSuite.

If I try setting TestSuite as an empty variable in pipelineB then pipelineAs value doesn't get used

Is there a way to use the parameter thats passed in only if its populated? Or another way of accessing the variable that will return empty if not found? I'm new to working with yaml so I don't know whats possible, any of the ways I've tried causes issues in either the standalone or the triggered pipeline

Hoyzer90 commented 3 years ago

I got this working by adding a variable to PipelineB with an empty value and enabling "Let users override this value when running this pipeline" image

Now when I run PipelineB on its own it runs the full projects tests, and PipelineA runs just the specified Test Suite.

Thanks for this extension its brilliant,

huserben commented 3 years ago

Hi @Hoyzer90

glad you could find a way to solve the issue. Thanks for reporting it anyway, now it might help others that come here looking for a solution for the same issue.

In case you find some other problems or have questions or feature request, please don't hesitate to open up another issue.