huserben / TfsExtensions

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

Unable to trigger build in the same Team Project without authentication #228

Closed jmptk closed 1 year ago

jmptk commented 1 year ago

Hi, I would like to ask if it is possible to trigger builds without authentication?

I Have checkbox: "True if the build to be triggered is defined within the same team project as this build with" set to true and also checkbox: "Queue Build for user that triggered original build" set to true.

Builds I want to trigger are in the same Team Project so there is no need for authentication.

From my understanding, the checkbox "Queue Build for user that triggered original build" should be enough in this case since I don't want to depend on any kind of authentication as is stated in info box: "If this option is enabled, the triggered build will run for the same user that triggered the original build. Otherwise the triggered user depends on the means of authentication."

Why is it so that in "Authentication" section, I see red star on "Authentication Method" as if it is mandatory? My previous checkbox should disable this option shouldn't it? So it behaves like it is mandatory since, I can't choose anything else besides : OAuth Token / Personal Access Token / Basic Authentication. There is no 4th option. I can't trigger builds.

I am using Azure DevOps 2019 and versions of the task available were 3., 4., both behave the same.

Can you please help me?

huserben commented 1 year ago

Hi @jmptk

you can't trigger anything "without authentication", as the the task works against the REST API which needs authentication. If you enable the checkbox to use the same team project you just need to configure less as the url/team project are automatically read.

Queue Build for user that triggered original build will just try to queue the build in this users name, it's a parameter that is passed to the triggered build and is not related to authentication.

The simplest way to deal with Authentication is to use OAuth and to pass the system access token.

In yaml you can do it like this:

    authenticationMethod: 'OAuth Token'
    password: $(System.AccessToken)

If you use classic builds, please refer to the docs: https://github.com/huserben/TfsExtensions/blob/master/BuildTasks/overview.md#authentication-options

Hope this helps, otherwise please get back to me

jmptk commented 1 year ago

Hi @huserben,

thank you for clarification. I managed to solve it by creating Personal Access Token under my Profile -> Security, store it in environment variable System.AccessToken and then pass it as parameter in Authentication section.

Best regards