Closed achim-t closed 3 years ago
Hi, It's a great idea! When the script started I added a check if the access token exist, if not - exit with error :) Thank you so much for the idea!
The temporary PAT is always exposed to ADO custom tasks. You just need to:
$token = (Get-VstsEndpoint -Name SystemVssConnection -Require).auth.parameters.AccessToken
Then you won't need people to check the OAuth box on the agent phase and the token will never be missing.
Thank you @Skymogul!! I just updated the extension and there is no need to check the OAuth box :) @achim-t FYI
https://github.com/shayki5/azure-devops-create-pr-task/blob/92eba10e2238f12b1b57fd30fcabc16cfdbad933/task/createPullRequest.ps1#L326 https://github.com/shayki5/azure-devops-create-pr-task/blob/5055ae55250407ab094ccde63c65fac7ba1d14cf/task/createPullRequest.ps1#L332-L334
If the script doesn't have access to the token, the response is not empty nor does the request throw an error (notice the missing PR ID).
A better way would be something like.
Or you could check that the access token isn't empty beforehand.