huserben / TfsExtensions

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

Add option to fail Task if conditions are not fulfilled #76

Closed abk90007 closed 6 years ago

abk90007 commented 6 years ago

We have four build definitions:

  1. Application
  2. Server
  3. Middle
  4. CI

In the "Middle" build definition we are using "Trigger Build Task" for triggering Application & Server builds if the "CI" build is succeeded. "Trigger Build Task" task is always succeeding even if my "CI" build is failed and builds were not triggered.

How to set the status of the "Trigger Build Task" on the basis of dependent "CI" build?

Ex: If my "CI" build is succeeded, then "Trigger build task" status is succeeded, and if "CI" build is failed, then "Trigger build task" status will be failed not succeeded.

Currently, Status is always succeeded

huserben commented 6 years ago

Hi @abk90007

in order to verify the result of a triggered build you would need to use the option to await a build. You can do this as part of the TriggerBuildTask directly under advanced configuration or in a separate task (Wait for Build) if you want to do other things in between. Please check out the section "Wait for Triggered Build Task" in the documentation at https://marketplace.visualstudio.com/items?itemName=benjhuser.tfs-extensions-build-tasks

Please note that Waiting for a Build will be blocking, so the build definition "Middle" is not proceeding until the awaited build is finished.

Let me know whether you were able to solve your problem like this.

abk90007 commented 6 years ago

Hi @huserben ,

I don't want to verify the result of triggered builds.

I need to set the status of the "Trigger Build Task" task as "Failed" when builds were not triggered because of "CI" failed status

huserben commented 6 years ago

Ah, so you have a condition set on the trigger and the Task to fail if any of the conditions is not fulfilled?

abk90007 commented 6 years ago

Yes

huserben commented 6 years ago

Ok. Yes I can look into adding this option.

I will let you know once a version with that feature would be available.

abk90007 commented 6 years ago

Would be nice if the timeline is another two weeks or so.

huserben commented 6 years ago

As I'm completly doing this in my free time, I won't and can't make you any promises on this. It doesn't sound like a big change, but still I need to see when I find the time to properly implement and test it.

abk90007 commented 6 years ago

Hi Huserben,

Thanks for the quick response. We are working in an agile project and need to deliver this functionality by Monday 4th June 2018. It would be nice if you could spare some time and resolve this issue.

Regards

Abhishek

huserben commented 6 years ago

Hi again

as said, I can't make promises as this is something I do apart from my regular job. So I will check it out as soon as I have the time.

Anyway what you could do to solve the issue by a workaround if you need this functionality quickly is that you store the triggered build id into the variable. Then you could add a script that evalutes whether this variable has any content. If so the build was triggered, if not, you could fail the task by failing the script.

huserben commented 6 years ago

Hi @abk90007

I just uploaded version 2.9.1 of the Task that contains an option to fail the task if any of the conditions are not fulfilled:

grafik

Please let me know whether this works for you as expected or not.

abk90007 commented 6 years ago

Thanks @huserben for quick implementation. Its been a great help. It works as expected.

Thanks, Abhishek