Closed pablorivassanchez closed 2 years ago
Hi @pablorivassanchez
The first thing I notice in your task is that you use the System.AccessToken but together with a "Personal Access Token" Authentication. To make use of the System.AccessToken you should use OAuth:
authenticationMethod: 'OAuth Token'
password: $(System.AccessToken)
If this does not make it work, I would assume the error would have to do with the templateParameter. Can you try to change the auhtentication method and let me know if it worked? If not, could you show the template parameters of the build you want to trigger (so the first few lines of your yaml definition).
Hello @huserben,
I change the authenticationMethod and remove for now the templateParameter but the error still remains:
- task: TriggerBuild@4 inputs: definitionIsInCurrentTeamProject: true buildDefinition: 'DC - [TEST] App Services Deployment' queueBuildForUserThatTriggeredBuild: true ignoreSslCertificateErrors: false useSameSourceVersion: false useCustomSourceVersion: false useSameBranch: true waitForQueuedBuildsToFinish: false storeInEnvironmentVariable: false # templateParameters: 'test:1' password: $(System.AccessToken) authenticationMethod: 'OAuth Token' enableBuildInQueueCondition: false dependentOnSuccessfulBuildCondition: false dependentOnFailedBuildCondition: false checkbuildsoncurrentbranch: false failTaskIfConditionsAreNotFulfilled: false
The other pipeline i remove all and just try to print the template parameter:
name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
trigger:
- none
pool: vmImage: ubuntu-latest
variables: azureSubscriptionEndpoint: AzureDevopsServiceConnection DockerNamespace: xxx solution: '*/.sln' buildPlatform: "Any CPU" buildConfiguration: "Release" RUN_NSWAG: 'false'
stages:
- stage: API_TEST_DEPLOY jobs:
- job: "API_TEST_DEPLOY"
steps:- bash: | echo "${{ parameters.test}}"
I'm missing something?
Thank you in advance.
Ok that's good information, thanks.
One thing I can't see is the test parameter in the build that is being triggered. Is this just missing in your yaml snippet or not there at all?
Also can you trigger the second pipeline manually? Is there any error appearing?
Another question, is the triggered pipeline using the same repo? As you are using "useSameBranch" it could be a problem if the respective branch does not exist. So another thing to try to narrow down on the problem could be to set "useSameBranch" to false for testing.
Hello @huserben,
How can i recieve the parameter from the inicial pipeline I mean how i define the test parameter in the triggered pipeline? I just remove the echo "${{ parameters.test}}" and put the useSameBranch to false and now is working but i dont know how to recieve the templateParameter in the second pipeline.
Thank you very much.
Hi
so if you want to use template parameters you have to define them in your yaml file. See the microsoft docs for more info.
In your case it probably would look something like this:
name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
trigger: none
pool:
vmImage: ubuntu-latest
parameters:
- name: test
displayName: Test Parameter
type: string
default: ""
Only then you can actually pass a template parameter, otherwise you will get an error from Azure DevOps (as it won't find the parameter to set when queuing the build).
If this works, you can undo the previous changes (useSameSourceBranch can go back to true and add the test template parameter again). The change to the authentication I would keep.
Can you try it like this and let me know whether it then works?
Hello,
I follow what you told me and what i read on the microsoft documentation but still fails:
- task: TriggerBuild@4 inputs: definitionIsInCurrentTeamProject: true buildDefinition: 'DC - [TEST] App Services Deployment' queueBuildForUserThatTriggeredBuild: true ignoreSslCertificateErrors: false useSameSourceVersion: false useCustomSourceVersion: false useSameBranch: false waitForQueuedBuildsToFinish: false storeInEnvironmentVariable: false templateParameters: 'test: prueba' password: $(System.AccessToken) authenticationMethod: 'OAuth Token' enableBuildInQueueCondition: false dependentOnSuccessfulBuildCondition: false dependentOnFailedBuildCondition: false checkbuildsoncurrentbranch: false failTaskIfConditionsAreNotFulfilled: false
and then the triggered pipeline:
name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
trigger:
- none
pool: vmImage: ubuntu-latest parameters:
- name: test type: string default: ""
variables: azureSubscriptionEndpoint: AzureDevopsServiceConnection solution: '*/.sln' buildPlatform: "Any CPU" buildConfiguration: "Release" RUN_NSWAG: 'false'
stages:
- stage: API_TEST_DEPLOY jobs:
- job: "API_TEST_DEPLOY"
steps:- bash: | echo test : ${{ parameters.test }}
Only works if i remove the templateParameter.
Ok this is strange. I have the following setup for testing and it works fine:
Pipeline that is triggered:
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
trigger: none
jobs:
- job: whatever
steps:
- script: echo myString - ${{parameters.myString}}
- script: echo myMultiString - ${{parameters.myMultiString}}
- script: echo myNumber - ${{parameters.myNumber}}
- script: echo myBoolean - ${{parameters.myBoolean}}
And I trigger it like this:
trigger: none
pool:
vmImage: ubuntu-latest
steps:
- task: TriggerBuild@4
inputs:
definitionIsInCurrentTeamProject: true
buildDefinition: '58'
queueBuildForUserThatTriggeredBuild: true
ignoreSslCertificateErrors: false
useSameSourceVersion: false
useCustomSourceVersion: false
useSameBranch: true
waitForQueuedBuildsToFinish: false
storeInEnvironmentVariable: false
templateParameters: 'myString: This is a string, myMultiString: ubuntu, myNumber: 8, myBoolean: false'
authenticationMethod: 'OAuth Token'
password: '$(System.AccessToken)'
enableBuildInQueueCondition: false
dependentOnSuccessfulBuildCondition: false
dependentOnFailedBuildCondition: false
checkbuildsoncurrentbranch: false
failTaskIfConditionsAreNotFulfilled: false
and that works fine, so I'm not sure why it's not working. You can run the pipeline manually and specify a value for the test parameter?
Hi @huserben,
The problem was that the definitivon of the parameter was inside the pool so the triggered pipeline fails.
Now i put the parameter in the beginning of the pipeline and all is working.
Thank you for your patient.
Ok cool, I'm glad that you could solve it.
Hi,
I'm trying to call a pipeline from another one but i get this error and i don't find any solution:
And the task that call the pipeline:
Thank you.