huserben / TfsExtensions

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

Create Task that is able to trigger a Release #9

Closed phatcher closed 2 years ago

phatcher commented 7 years ago

I'd like to trigger a release passing in the current build artefact details.

Idea is to fan-out the deployment so that I can control either a component or an AppService indepedently e.g. I've run all the integration tests so the code works now I want a separate release pipeline for the main web and each webjob; I might have a patch to one job that I need to push to prod, but the other elements can wait.

huserben commented 7 years ago

Hi Paul

the Tasks is based on the REST API of TFS/VSTS. For the release management, the API is currently just in Preview state (https://www.visualstudio.com/en-us/docs/integrate/api/rm/overview). Right now I haven't looked at it.

Just looking at the documents it seems that the REST calls should be very similar, but I would probably create a separate task for triggering releases. Right now I can't tell you when I would implement the task. But I want to rewrite the Task in the future from PowerShell to TypeScript to make it usable on Linux Agents as well. When this happens I would for sure keep this use case in mind and make the common parts reusable so creating a second task should not be to big of a big deal.

If you feel like it you can as well try to adjust the current PowerShell script to work with the ReleaseManagement as described in the above link.

Feel free to come back to me if you have any questions and thanks for your input.

huserben commented 7 years ago

Hi again

so i was just playing around a bit and I managed to queue a release via the REST API. Could you maybe quickly specify the requirements you exactly have. I have not really worked with the Releases so far so I might miss something :-)

Do you want to queue a new release from a Build or from another Release? And do you need the conditions as they exist for the Build Task. If you need them, will it be bound to another build or to a release (or even both)?

And last, do you need to specify something towards the release, I saw that in order to queue a new Release a list of artifacts need to be passed, but I'm not sure if this is even configurable or if it will always be the same (as mentioned, I never worked with the Release so far).

If you could provide me with the answers to the questions above I would be able to make a more educated guess about how complex (and therefore how long) it would take to implement something.

Thanks for your help

huserben commented 7 years ago

Hi @phatcher still interested in this functionality or did you solve it in an other way?

dwhearn commented 6 years ago

I currently have an MSBuild task which uses the REST API to queue Releases and would like to convert it to a Build task. As you said, it is very similar to how Builds are queued. I queue a Release from a Build, but could see the need to eventually want to queue one from another Release. Currently don't have a need for the same conditions as they exist for the Build Task.

When queuing a release, I specify the Release Definition name or ID, the Build Definition name for the source of the queued release, the Build ID and Build Number of the completed build. Optionally, the Description and Branch can be specified.

huserben commented 6 years ago

Hi @dwhearn

do you have the code for your task somewhere available. I could look into creating a task for this and extending the my service to query the TFS Rest API for queuing Releases. However if I have some working code as a base it probably would be quicker :-)

The parameters you specify are necessary for every release or this is tied to your specific use case. As I don't have experience whatsoever with Release Definitions etc. I'm glad for any input I could get.

Just as a sidenote, I'm currently not so flexible in time, so don't expect that such a task will be done within the next few days, however with enough info I might be able to look into that over the christmas period.

dwhearn commented 6 years ago

Here is the code that implements a QueueBuild and QueueRelease MSBuild tasks. It uses a helper class for the common code used between the queuing builds and releases.

The required parameters I listed are necessary when queuing any release, Description and Branch are optional.

QueueBuildTask.zip

Hope this helps.

huserben commented 6 years ago

Hi yes, that helps, thank you.

I'll have a look at it as soon as time allows.

I might come back with questions to you if I need any input or clarification.

Thanks already for helping on improving and extending the task, it's very much appreciated.

huserben commented 6 years ago

Hi @phatcher , @dwhearn

I just checked out the Release API a bit and then I stumbled over this functionality in VSTS: grafik

Isn't this more or less what would be needed by you guys?

I'm not sure how easy it will be to create a Task that will work on all configurations, as apparently there are different types or artifacts (Build, Git, Github, Azure etc.) and you can even have more than one for every Release. This makes it quite dynamic and thus hard to be able to configure this properly from the Task... So if someone could clarify that for me it would be good, before a lot of time is invested in something that is already there :-)

patnolan commented 6 years ago

Hi @huserben,

Unfortunately we're running with TFS on-prem so our version looks different to your screenshot, however, I think this would only work if there is one Release Definition pulling the artifacts from one or more Build Definitions. In contrast, we need to order the execution of 3 separate Release Definitions.

Our scenario is...

We're using your Trigger Build extension from a Master build definition to order the execution of 3 other build definitions. However, upon successful completion of the Master build, we need a Master release definition to order the execution of 3 Release definitions.

phatcher commented 6 years ago

Hi @huserben

I think my use-case is similar to @patnolan but with VSTS - I already use the continuous deployment trigger but I wanted to to have a conditional trigger of another release pipeline depending on some conditions.

I might be able to do this with the new phases capability, but I need to work this out

huserben commented 6 years ago

Hi @patnolan and @phatcher

thanks for the input. Ok that clears it up for me. However I'm sorry to dissappoint but I can't give you any reliable shedule on when I will be able to look at this, as currently I'm fully loaded with regular work and I cannot find the time to properly add this functionality. In the meantime I saw that MS is working on the functionality to trigger builds from other builds (https://visualstudio.uservoice.com/forums/330519-visual-studio-team-services/suggestions/2165043-provide-build-configuration-dependencies-in-tfs-bu), so maybe this will include as well the functionality to trigger releases.

Anyway I will keep you guys posted in this issue if there is any news from my side regarding the task.

cveld commented 4 years ago

@huserben have you taken a look at https://github.com/maikvandergaag/msft-extensions/blob/master/azuredevops/triggerpipeline/ ?

It implements means to queue a release. Unfortunately it does not include the wait-for-pipeline.

Additional feature is the custom service provider that is included. Maybe something you could also adopt. The picklist discovery (task data sources) for selecting a project and a particular build works perfectly!

huserben commented 4 years ago

HI @cveld

Thanks for letting me know about this.

The truth however is that currently I'm not having too much time to work on any new featurers, so I would not expect that anything happens in that direction any time soon.

Sorry to dissapoint - however if I will find time I'll definetly check the other task out :-)

huserben commented 2 years ago

I saw that this is still open. However I'm quite certain I won't ever implement this feature. Thus I'm closing the issue. If someone else would like to take up feel free, but I won't have the time or energy in the foreseeable future for it :-)