tfsaggregator / aggregator-cli

A new version of Aggregator aiming at Azure DevOps (ex Visual Studio Team Services)
https://tfsaggregator.github.io/
Apache License 2.0
74 stars 32 forks source link

Apply some generic rules at organization level to all projects #73

Open KamranAslamBhatti opened 5 years ago

KamranAslamBhatti commented 5 years ago

Hi, Is there any way we can apply a common rule at organization level to all projects under that organization and also when any new project created under that organization then that rule by default applies to the new project too. Following is example:

giuliov commented 5 years ago

You pose two questions:

  1. apply a rule to a whole organisation
  2. automatically add rules when a project is created

The first answer is yes: you can deploy a single rule and add a mapping to each and every project in the org so they all invoke the same rule. Clearly the rule has to take in consideration the event context (say project A and B do not have the same set of work item types, like an Agile vs Scrum project) to work correctly. Aggregator has no facility for organisation, you need to invoke it multiple times. I take note and see to add some helpers post 1.0 release.

I am lean to answer no to the second part: TFS/AzDOS have no public event for a new project. You have two ways to work around this limit:

I can help you with directions and I will research if this is the definitive answer.

giuliov commented 5 years ago

After more digging I found a positive answer to the second question: there is a way to be notified when a project is created (or removed). Implementation is non trivial so we will implement it after release 1.0.

Please @KamranAslamBhatti share your thinking; do not close the issue as it will help us track the feature in the backlog.

KamranAslamBhatti commented 5 years ago

Giuliov, Could you please share how can we do the following:

Thanks, Kamran

giuliov commented 5 years ago

As I said, implementation is non-trivial: one should add many things to Aggregator CLI and its runtime. Things that come to mind:

You can submit a PR that implements the above items, I would be delighted to review and merge it.

RSMJreck commented 4 years ago

@giuliov - Could you point me to where the Project events are? I've been looking everywhere that I can think of to find where you could get notified a project is created and haven't been able to find it. I might be able to start some work around this to get it started.

giuliov commented 4 years ago

I cannot find any notes on the "non trivial" solution and, as I wrote in the initial response, there are no events in public docs.

An idea is to use a Timer binding instead of the normal HTTP binding. The difference should be confined to the aggregator-function project. I guess it would be better to specialise run.csx per "logical" event type: from FunctionTemplate/run.csx to FunctionTemplates/workitem/run.csx, FunctionTemplates/project/run.csx ecc. This has a cascade effect: AzureFunctionHandler.RunAsync method cannot retrieve the workitem, the self object in rules is now a project object; probably need some declaration in the rule to prevent mapping errors (a rule designed for project event mapped to a workitem event). Finally the timer function need some permanent store to note when a project is added/deleted (diff'ing state) and invoke the rule.

We can use Slack for discussing details, if you like the idea.

Also @jessehouwing may have some smart idea on this topic.

jessehouwing commented 4 years ago

You could use the new streaming API for audit events... New project surely is an audit event... I wonder whether the api could scope a service hook at the collection level, haven't tried that yet...

On Thu, Apr 23, 2020, 23:58 Giulio Vian notifications@github.com wrote:

I cannot find any notes on the "non trivial" solution and, as I wrote in the initial response, there are no events in public docs.

An idea is to use a Timer binding https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer instead of the normal HTTP binding. The difference should be confined to the aggregator-function project. I guess it would be better to specialise run.csx per "logical" event type: from FunctionTemplate/run.csx to FunctionTemplates/workitem/run.csx, FunctionTemplates/project/run.csx ecc. This has a cascade effect: AzureFunctionHandler.RunAsync method cannot retrieve the workitem, the self object in rules is now a project object; probably need some declaration in the rule to prevent mapping errors (a rule designed for project event mapped to a workitem event). Finally the timer function need some permanent store to note when a project is added/deleted (diff'ing state) and invoke the rule.

We can use Slack https://slackin-tfsaggregator.herokuapp.com/ for discussing details, if you like the idea.

Also @jessehouwing https://github.com/jessehouwing may have some smart idea on this topic.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tfsaggregator/aggregator-cli/issues/73#issuecomment-618690340, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA724S2ZFWZSNYXUVRSXQHTROC2Y7ANCNFSM4IP6TQNQ .

RSMJreck commented 4 years ago

The audit looks promising. I'll try to play around with it a little.