Closed krispenner closed 4 years ago
Hi @krispenner
This error seems to come from Azure DevOps itself -what you can try to do is to set the system.debug variable of the build to true and see whether we would get more information.
If that still doesn't work, you could try to comment out the build parameters to check whether it works then. If so there is probably something off with the format (I don't see anything right away, but it's usually the culprit :-))
Edit: I think the build parameters should be enclosed in ': buildParameters: 'api:$(apiName)-v$(apiVersion),env:$(environment)'
Hi @huserben, thank you for your reply. If you see my earlier comment please disregard, it was incorrect and so I have deleted it to avoid confusion.
The issue appears to be that only Variables can be passed and not Runtime Parameters. Can you confirm that statement? The documentation is a bit misleading in that case since you use the words variables and parameters interchangeably and they are two different things in pipelines - granted runtime parameters were only added in late 2019. I had defined runtime parameters on my builds and these are not being set. But if I remove the parameters and use variables instead it works. Maybe this triggerBuild task does support passing runtime parameters and you can point me to how to do that? Using runtime parameters provides a much better experience for manual UI driven build triggers which my target pipeline also needs to support.
In the meantime I'm going to look into how I can use both runtime parameters and variables; potentially a script task could check if a variable value was provided and if so use it's value otherwise use the runtime parameter value.
FYI, I was able to get the trigger passed variables to work and if not specified due to manual start then fallback to the runtime parameters. Still curious if runtime parameters should be supported and I'm missing something?
Triggering build:
buildParameters: triggerApi:$(api),triggerEnv:$(env)
Triggered build
parameters:
- name: api
displayName: API
type: string
default: api1
values:
- api1
- api2
- name: env
displayName: Environment
type: string
default: DEV
values:
- DEV
- QA
- PROD
variables:
paramApi: ${{ parameters.api }}
paramEnv: ${{ parameters.env }}
api: $[ coalesce(variables.triggerApi, variables.paramApi) ]
env: $[ coalesce(variables.triggerEnv, variables.paramEnv) ]
Hi @krispenner
sorry for the late reply.
Nice that you figured it out, thanks for putting the effort into investigating the problem. I did not consider runtime parameters thus far, so there is no functionality implemented for them.
As you mentioned they are rather new and before there were "only" the variables. Sorry if it wasn't clear enough from the docs - I might add a statement for clarification.
I checked very quickly about the runtime parameters and saw that there seems to be in general a way of doing it: https://stackoverflow.com/questions/60852825/azure-devops-yaml-pipeline-parameters-not-working-from-rest-api-trigger
However I would need to check if the api is even supporting it at the moment. This looks like it's a similar problem as yours, what is called "parameters" in the request is what is known to the user as "variable", "runtime parameters" seem to use the name template parameters. https://github.com/microsoft/azure-devops-node-api/issues/392
So for now the plan would be to mention the lack of support for runtime parameters, I hope that's ok, as you got a workaround for your problem at the moment.
@huserben that all sounds great! Yes I have it working perfectly now. If I ever see you update this to support runtime parameters then I will look to update my side as well and remove the extra bit I added to work around this. Thank you so much for all your help and amazing task! I'll close this issue as the error I had was resolved.
Also a bit of background on parameters, I believe they were added as Template Parameters initially and only used when passing parameters from one pipeline to a YAML template. So the name Template Parameters came from that. Then more recently they added support to provide these same parameters at queue time of a pipeline but called these ones Runtime Parameters although they are the same thing really the name determines where you are specifying them. For this reason I think the REST API you use just re-uses the original templateParameters property as you found out.
{
"stagesToSkip": [],
"resources": {
"repositories": {
"self": {
"refName": "refs/heads/master"
}
}
},
"templateParameters": {
"testParam": "hello world"
},
"variables": {}
}
from the link you shared
I came across this answer in a search for fixing a problem I thought was coming from how I was sending parameters from one pipeline job to another from the Azure CLI (using the Azure DevOps CLI extension).
At first, the documentation I found on az pipelines run
conveyed a notion to me that you could only pass variables, not parameters. Then, the above code snippet from @krispenner was super-useful, but still causing me trouble because I was also trying to import values from a variable group whose name would change depending on what the environment would be, and unfortunately the name of a variable group has to be known at compile time (i.e. with parameters, not variables).
Then, continuing my search, I came across this GitHub feature request where they mention adding the parameters
field to the CLI, thus enabling me to carry on with my original plan anyway. After a bit more searching, I came across this slightly different piece of Microsoft documentation that contains the updated Pipelines CLI spec featuring the parameters
field.
Hopefully this helps anyone who is confused about conditionally launching pipelines from other pipelines. I meant to blog about this last night too but got sidetracked; I'll hopefully publish it next week, and meanwhile have Microsoft reconcile their documentation.
@mrcity Looking forward to reading your post. Feel free to leave a link here. It might help others that stumble over this problem.
@huserben Here's the link! https://goshtastic.blogspot.com/2023/02/start-azure-pipeline-from-another.html There could be enough here for a conference talk 😛
Hey guys!
I'm getting the same error on a build that was working this morning and stopped working for some reason:
jobs:
- job: "TriggerKbPipeline"
condition:
variables:
AgentString: $[stageDependencies.CreatePrimeVersion.CreatePrimeVersionJob.outputs['AVersion1.AgentVersion']]
AgentString2: $[stageDependencies.CreatePrimeVersion.CreatePrimeVersionJob.outputs['AVersion2.AgentVersion']]
pool:
vmImage: ubuntu-latest
steps:
- task: TriggerBuild@4
condition: or(eq('${{ parameters['AgentVersion'] }}', ''), eq('${{ parameters['AgentVersion'] }}', 'latest'))
inputs:
definitionIsInCurrentTeamProject: true
buildDefinition: 'KB'
queueBuildForUserThatTriggeredBuild: true
ignoreSslCertificateErrors: false
useSameSourceVersion: false
useCustomSourceVersion: false
useSameBranch: false
branchToUse: $(branchName)
waitForQueuedBuildsToFinish: true
waitForQueuedBuildsToFinishRefreshTime: '10'
failTaskIfBuildsNotSuccessful: true
cancelBuildsIfAnyFails: false
treatPartiallySucceededBuildAsSuccessful: false
downloadBuildArtifacts: false
storeInEnvironmentVariable: false
authenticationMethod: 'OAuth Token'
password: $(System.AccessToken)
enableBuildInQueueCondition: false
dependentOnSuccessfulBuildCondition: false
dependentOnFailedBuildCondition: false
checkbuildsoncurrentbranch: false
failTaskIfConditionsAreNotFulfilled: false
buildParameters: "GitSemVer: $(StagesSemVer), AgentVersion: $(AgentString)"
- task: TriggerBuild@4
condition: and(ne('${{ parameters['AgentVersion'] }}', ''), ne('${{ parameters['AgentVersion'] }}', 'latest'))
inputs:
definitionIsInCurrentTeamProject: true
buildDefinition: 'KB'
queueBuildForUserThatTriggeredBuild: true
ignoreSslCertificateErrors: false
useSameSourceVersion: false
useCustomSourceVersion: false
useSameBranch: false
branchToUse: $(branchName)
waitForQueuedBuildsToFinish: true
waitForQueuedBuildsToFinishRefreshTime: '10'
failTaskIfBuildsNotSuccessful: true
cancelBuildsIfAnyFails: false
treatPartiallySucceededBuildAsSuccessful: false
downloadBuildArtifacts: false
storeInEnvironmentVariable: false
authenticationMethod: 'OAuth Token'
password: $(System.AccessToken)
enableBuildInQueueCondition: false
dependentOnSuccessfulBuildCondition: false
dependentOnFailedBuildCondition: false
checkbuildsoncurrentbranch: false
failTaskIfConditionsAreNotFulfilled: false
buildParameters: "GitSemVer: $(StagesSemVer), AgentVersion: $(AgentString2)"
Hello Guy's this extension is not working when we are running it from a particuler branch below is the configuration(except when we are merging) and error is given below:
Call to the template which contain TriggerBuild@4 task:
jobs:
- job: triggetest
displayName: trigger tests
steps:
- task: TriggerBuild@4
inputs:
definitionIsInCurrentTeamProject: true
buildDefinition: project-tests
queueBuildForUserThatTriggeredBuild: true
ignoreSslCertificateErrors: false
useSameSourceVersion: false
useCustomSourceVersion: false
useSameBranch: true
waitForQueuedBuildsToFinish: true
storeInEnvironmentVariable: false
authenticationMethod: Personal Access Token
password: $(PAT_VARIABLE)
enableBuildInQueueCondition: false
dependentOnSuccessfulBuildCondition: false
dependentOnFailedBuildCondition: false
checkbuildsoncurrentbranch: false
failTaskIfConditionsAreNotFulfilled: false
Debug log:
2023-02-14T18:49:39.8112592Z ##[section]Starting: TriggerBuild
2023-02-14T18:49:39.8122520Z ==============================================================================
2023-02-14T18:49:39.8122760Z Task : Trigger Build
2023-02-14T18:49:39.8122877Z Description : This tasks allows to trigger a new Build (add it to the queue) as part of a Build Definition. It contains as well some conditions that can be applied, for example if the last build of certain definition was successful or not.
2023-02-14T18:49:39.8123277Z Version : 4.1.1
2023-02-14T18:49:39.8123387Z Author : Benjamin Huser
2023-02-14T18:49:39.8123565Z Help :
2023-02-14T18:49:39.8123679Z ==============================================================================
2023-02-14T18:49:39.9169740Z ##[debug]Using node path: /home/vsts/agents/2.217.2/externals/node10/bin/node
2023-02-14T18:49:40.2209905Z ##[debug]agent.TempDirectory=/home/vsts/work/_temp
2023-02-14T18:49:40.2225332Z ##[debug]loading inputs and endpoints
2023-02-14T18:49:40.2231187Z ##[debug]loading INPUT_DEFINITIONISINCURRENTTEAMPROJECT
2023-02-14T18:49:40.2247321Z ##[debug]loading INPUT_BUILDDEFINITION
2023-02-14T18:49:40.2250394Z ##[debug]loading INPUT_QUEUEBUILDFORUSERTHATTRIGGEREDBUILD
2023-02-14T18:49:40.2252182Z ##[debug]loading INPUT_IGNORESSLCERTIFICATEERRORS
2023-02-14T18:49:40.2253823Z ##[debug]loading INPUT_USESAMESOURCEVERSION
2023-02-14T18:49:40.2255444Z ##[debug]loading INPUT_USECUSTOMSOURCEVERSION
2023-02-14T18:49:40.2257018Z ##[debug]loading INPUT_USESAMEBRANCH
2023-02-14T18:49:40.2258948Z ##[debug]loading INPUT_WAITFORQUEUEDBUILDSTOFINISH
2023-02-14T18:49:40.2260544Z ##[debug]loading INPUT_WAITFORQUEUEDBUILDSTOFINISHREFRESHTIME
2023-02-14T18:49:40.2262193Z ##[debug]loading INPUT_FAILTASKIFBUILDSNOTSUCCESSFUL
2023-02-14T18:49:40.2263646Z ##[debug]loading INPUT_CANCELBUILDSIFANYFAILS
2023-02-14T18:49:40.2265235Z ##[debug]loading INPUT_TREATPARTIALLYSUCCEEDEDBUILDASSUCCESSFUL
2023-02-14T18:49:40.2266783Z ##[debug]loading INPUT_DOWNLOADBUILDARTIFACTS
2023-02-14T18:49:40.2268312Z ##[debug]loading INPUT_DROPDIRECTORY
2023-02-14T18:49:40.2269884Z ##[debug]loading INPUT_STOREINENVIRONMENTVARIABLE
2023-02-14T18:49:40.2271448Z ##[debug]loading INPUT_DELAYBETWEENBUILDS
2023-02-14T18:49:40.2273129Z ##[debug]loading INPUT_AUTHENTICATIONMETHOD
2023-02-14T18:49:40.2274706Z ##[debug]loading INPUT_PASSWORD
2023-02-14T18:49:40.2276297Z ##[debug]loading INPUT_ENABLEBUILDINQUEUECONDITION
2023-02-14T18:49:40.2277918Z ##[debug]loading INPUT_INCLUDECURRENTBUILDDEFINITION
2023-02-14T18:49:40.2279531Z ##[debug]loading INPUT_BLOCKINPROGRESSBUILDS
2023-02-14T18:49:40.2281079Z ##[debug]loading INPUT_DEPENDENTONSUCCESSFULBUILDCONDITION
2023-02-14T18:49:40.2282658Z ##[debug]loading INPUT_DEPENDENTONFAILEDBUILDCONDITION
2023-02-14T18:49:40.2284209Z ##[debug]loading INPUT_CHECKBUILDSONCURRENTBRANCH
2023-02-14T18:49:40.2285808Z ##[debug]loading INPUT_FAILTASKIFCONDITIONSARENOTFULFILLED
2023-02-14T18:49:40.2287368Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2023-02-14T18:49:40.2288984Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2023-02-14T18:49:40.2290558Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2023-02-14T18:49:40.2295597Z ##[debug]loading SECRET_PAT_VARIABLE
2023-02-14T18:49:40.2297577Z ##[debug]loading SECRET_TOKEN
2023-02-14T18:49:40.2299661Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2023-02-14T18:49:40.2301222Z ##[debug]loaded 31
2023-02-14T18:49:40.2306344Z ##[debug]Agent.ProxyUrl=undefined
2023-02-14T18:49:40.2308123Z ##[debug]Agent.CAInfo=undefined
2023-02-14T18:49:40.2308606Z ##[debug]Agent.ClientCert=undefined
2023-02-14T18:49:40.2309114Z ##[debug]Agent.SkipCertValidation=undefined
2023-02-14T18:49:40.2324562Z ##[debug]definitionIsInCurrentTeamProject=true
2023-02-14T18:49:40.2325126Z ##[debug]tfsServer=undefined
2023-02-14T18:49:40.2326726Z ##[debug]teamProject=undefined
2023-02-14T18:49:40.2338926Z ##[debug]buildDefinition=**project-totrigger**
2023-02-14T18:49:40.2346023Z ##[debug]ignoreSslCertificateErrors=false
2023-02-14T18:49:40.2346577Z ##[debug]queueBuildForUserThatTriggeredBuild=true
2023-02-14T18:49:40.2347113Z ##[debug]useSameSourceVersion=false
2023-02-14T18:49:40.2347623Z ##[debug]useCustomSourceVersion=false
2023-02-14T18:49:40.2348141Z ##[debug]customSourceVersion=undefined
2023-02-14T18:49:40.2348643Z ##[debug]useSameBranch=true
2023-02-14T18:49:40.2349128Z ##[debug]branchToUse=undefined
2023-02-14T18:49:40.2349642Z ##[debug]waitForQueuedBuildsToFinish=true
2023-02-14T18:49:40.2350185Z ##[debug]waitForQueuedBuildsToFinishRefreshTime=60
2023-02-14T18:49:40.2350733Z ##[debug]failTaskIfBuildsNotSuccessful=true
2023-02-14T18:49:40.2351242Z ##[debug]cancelBuildsIfAnyFails=false
2023-02-14T18:49:40.2351780Z ##[debug]treatPartiallySucceededBuildAsSuccessful=false
2023-02-14T18:49:40.2352307Z ##[debug]downloadBuildArtifacts=false
2023-02-14T18:49:40.2352799Z ##[debug]dropDirectory=/home/vsts/work
2023-02-14T18:49:40.2353459Z ##[debug]storeInEnvironmentVariable=false
2023-02-14T18:49:40.2354920Z ##[debug]demands=undefined
2023-02-14T18:49:40.2355391Z ##[debug]queueid=undefined
2023-02-14T18:49:40.2357344Z ##[debug]buildParameters=undefined
2023-02-14T18:49:40.2357836Z ##[debug]templateParameters=undefined
2023-02-14T18:49:40.2358319Z ##[debug]delayBetweenBuilds=0
2023-02-14T18:49:40.2359823Z ##[debug]authenticationMethod=Personal Access Token
2023-02-14T18:49:40.2360329Z ##[debug]username=undefined
2023-02-14T18:49:40.2361439Z ##[debug]password=***
2023-02-14T18:49:40.2361930Z ##[debug]enableBuildInQueueCondition=false
2023-02-14T18:49:40.2362446Z ##[debug]includeCurrentBuildDefinition=true
2023-02-14T18:49:40.2362948Z ##[debug]blockingBuildsList=undefined
2023-02-14T18:49:40.2363448Z ##[debug]blockInProgressBuilds=false
2023-02-14T18:49:40.2363961Z ##[debug]dependentOnSuccessfulBuildCondition=false
2023-02-14T18:49:40.2364481Z ##[debug]dependentBuildsList=undefined
2023-02-14T18:49:40.2364997Z ##[debug]dependentOnFailedBuildCondition=false
2023-02-14T18:49:40.2365517Z ##[debug]dependentFailingBuildsList=undefined
2023-02-14T18:49:40.2366026Z ##[debug]checkbuildsoncurrentbranch=false
2023-02-14T18:49:40.2366546Z ##[debug]failTaskIfConditionsAreNotFulfilled=false
2023-02-14T18:49:40.2366891Z Using current Team Project
2023-02-14T18:49:40.2367353Z Team Project: xxxxxxxxxxxxxx
2023-02-14T18:49:40.2367674Z Using current Collection Url
2023-02-14T18:49:40.2367986Z Server URL: https://dev.azure.com/xxxxx/
2023-02-14T18:49:40.2368292Z Using following Authentication Method: Personal Access Token
2023-02-14T18:49:40.2368593Z Using Personal Access Token
2023-02-14T18:49:40.9118113Z Provided team project was guid.
2023-02-14T18:49:40.9120843Z Context is Build - using Build Environment Variables
2023-02-14T18:49:40.9122670Z Build shall be triggered for same user that triggered current build: **Trigger-build**
2023-02-14T18:49:40.9124313Z Using same branch as source version: refs/heads/release/1.xx.xx
2023-02-14T18:49:41.2480899Z Error during request (1/5)
2023-02-14T18:49:41.2481363Z Error message: Error: Could not queue the build because there were validation errors or warnings.
2023-02-14T18:49:41.2481781Z Will wait 1 seconds before retrying request...
2023-02-14T18:49:42.3277135Z Error during request (2/5)
2023-02-14T18:49:42.3298397Z Error message: Error: Could not queue the build because there were validation errors or warnings.
2023-02-14T18:49:42.3298966Z Will wait 2 seconds before retrying request...
2023-02-14T18:49:44.4238810Z Error during request (3/5)
2023-02-14T18:49:44.4239218Z Error message: Error: Could not queue the build because there were validation errors or warnings.
2023-02-14T18:49:44.4239593Z Will wait 4 seconds before retrying request...
2023-02-14T18:49:49.1705985Z Error during request (4/5)
2023-02-14T18:49:49.1707123Z Error message: Error: Could not queue the build because there were validation errors or warnings.
2023-02-14T18:49:49.1707588Z Will wait 8 seconds before retrying request...
2023-02-14T18:49:56.5810692Z Error during request (5/5)
2023-02-14T18:49:56.5811465Z Error message: Error: Could not queue the build because there were validation errors or warnings.
2023-02-14T18:49:56.5813144Z ##[debug]task result: Failed
2023-02-14T18:49:56.5863348Z ##[error]Request failed after 5 tries - see error messages in the log
2023-02-14T18:49:56.5872184Z ##[debug]Processed: ##vso[task.issue type=error;]Request failed after 5 tries - see error messages in the log
2023-02-14T18:49:56.5880428Z ##[debug]Processed: ##vso[task.complete result=Failed;]Request failed after 5 tries - see error messages in the log
2023-02-14T18:49:56.5893517Z ##[section]Finishing: TriggerBuild
2023-02-14T18:49:56.8699309Z ##[debug]Evaluating condition for step: 'Checkout **called-project**@release/1.xx.xx to s'
2023-02-14T18:49:56.8701036Z ##[debug]Evaluating: AlwaysNode()
2023-02-14T18:49:56.8701471Z ##[debug]Evaluating AlwaysNode:
2023-02-14T18:49:56.8703502Z ##[debug]=> True
2023-02-14T18:49:56.8704073Z ##[debug]Result: True
2023-02-14T18:49:56.8704514Z ##[section]Starting: Checkout **called-project**@release/1.xx.xx to s
NB: Some of the values like called-project and Trigger-build has been replaced with dummey name!
Hi @dasbiswajit
can you try to trigger it for your main/master branch and see if this is working? Is the pipeline that is triggered working against the same git repository, so the specific branch ("refs/heads/release/1.xx.xx") is available for this pipeline? What happens if you try to manually trigger this pipeline for that specific branch?
Hello @huserben with merging to master it is working. while running on release/1.x.x it is not working.
@dasbiswajit Ok, that is kind of the default case as most often the branch named master is available. My assumption now is that your pipeline runs against another git repo than the pipeline that triggers the build. Could you confirm/reject this assumption?
In case this is true and you are using a different repo for the triggered pipeline, my next assumption would be that in this repo you lack the branch name ("release/1.xx.xx") and this is why it can't trigger the pipeline.
Would you be so kind and let me know if the above is correct?
@huserben OK. yes- These are two different pipelines. Unfortunately the called pipeline does not have the same branch ("release/1.xx.xx") as the caller pipeline. Rathert it has master branch. Is there any way we can pass the branch name?
@huserben can you please update us? this is blocking our Deployment.
Hi @dasbiswajit sorry, must have missed that you were writing 2 weeks ago.
Ok if you don't have the same branch, you can't have "useSameBranch" set true
. If you set it to false
you can specify the branch you want to use:
You can also leave it empty and then it will trigger the pipeline on the default branch. See also https://github.com/huserben/TfsExtensions/blob/master/BuildTasks/overview.md#use-same-source-branch
I'm getting the following error: "Could not queue the build because there were validation errors or warnings." But no more detail than that. Is there any verbose logging I can turn on that might help show what the validation errors and warnings are?
Here is my YAML task:
Here is the task output:
Thank you!