huserben / TfsExtensions

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

Build not Triggered if there are no active Build Agents #50

Closed Tadimsky closed 6 years ago

Tadimsky commented 6 years ago

Hey, I have a queue with one agent that is offline sometimes. I want the build to be queued so that it will run that build when the agent is back online. It seems that it's failing in the Trigger stage though due to this error:

2018-02-16T19:09:27.0624369Z Could not queue the build because there were validation errors or warnings: 2018-02-16T19:09:27.0625371Z warning: There are agents that are capable of running the build, but they are not online. If the agent is configured to run as a service, ensure that the "VSTS Agent ({agent name})" service is running. 2018-02-16T19:09:27.0634097Z ##[error]Could not Trigger build. See console for more Information. 2018-02-16T19:09:27.0729600Z ##[section]Finishing: Trigger Build of StoreBroker Package

Is this something that can be done?

huserben commented 6 years ago

Hi @Tadimsky

Which version of TFS do you use (or do you use VSTS)? And which version of the task did you get this issue with? I tried quickly in my environment by dsiabling all the agents and it queued the build anyway...

Edit: But in the end there is only little I can do. I check the validation messages only if the return value from the Server is not in the shape that i expect. In this use case it means I cannot fetch any id of builds that were triggered because apparently in your TFS/VSTS Instance no build was actually queued. So maybe there is some setting somewhere to allow it to be queued anyways if no Agent is available, then the Task should queue it and complete without complaining...

Tadimsky commented 6 years ago

I'm running on VSTS.

My version is 2.* it seems: image

I'll get in touch with the VSTS folks and see if something is missing - thanks!

Tadimsky commented 6 years ago

I heard from the VSTS team and they were wondering if the request URL contains ?ignoreWarnings=true? Apparently, that will work.

huserben commented 6 years ago

Hi

ok thanks for checking that. It does not contain the flag so far, but I can add it with the next version. However as I'm not able to reproduce the warning itself I won't be able to verify it.

I'll let you know here once I uploaded a new version of the task with the fix included.

Tadimsky commented 6 years ago

Thanks! Ok, let me know if you have something you'd like me to test - I can take my agents offline to see what happens. This is what I heard from them:

When you attempt to queue a build when no agents are online, we will report that warning and not queue the build. When you ignoreWarnings, we will queue the build and it will stay queued until an agent picks it up.

You can see this behavior in action if you queue the build through the vsts ui. If there are no online agents, the dialog will tell you. You can then choose to queue it anyway. Watch the traffic with F12 or fiddler to see.

huserben commented 6 years ago

ah ok thanks for the clarification, i always only tried disabling the agents but they were still online. In that scenarios the build is actually queued without warning. When I create a new AgentQueue with no agents in I get the same issue as you. So I will be able to test it and verify it myself, thanks for your effort in finding the issue and the underlying problem in VSTS.

Once I have an update I will let you know here.

huserben commented 6 years ago

Hi @Tadimsky

I just uploaded version 2.6.0 of the Task which includes a fix for your problem. Now in case of an offline agent, it will queue the build anyway. The validation warning that the server will put in the response will be logged as part of the task.

Please update the task and let me know if its working or not for your use case now.

Tadimsky commented 6 years ago

Awesome, thanks!! I can't see a way to check the version of the extension I have - I assume it installs the latest automatically. So, I'll give it a try with the build agents offline and see what happens - thanks!

huserben commented 6 years ago

You would see the version in the beginning of the task's log. But if you us VSTS it's updating automatically ;-)

huserben commented 6 years ago

Hi @Tadimsky

did you have any chance to verify the functionality already? :-)

Tadimsky commented 6 years ago

Hey! I just gave it a shot now and it seemed to work! I got the following output:

2018-02-28T01:42:04.3542896Z warning: There are agents that are capable of running the build, but they are not online. If the agent is configured to run as a service, ensure that the "VSTS Agent ({agent name})" service is running.

I'm not sure if it's worth writing that output as a Warning to VSTS instead of a message?

Thanks very much for doing this :)

huserben commented 6 years ago

Hi

yeah I thougt it might makes sense, however I can as well switch it back to a "regular" log message. Anyway I won't create a new version just for that, but I'll include it in the next version.

I will therefore close the Issue. Thanks for reporting and investigating into what casues the problem and how it can be solved. And please do raise other Issues if you find a problem or you have some additional functionality in mind.

Tadimsky commented 6 years ago

Sounds good! Thanks! 👍