Giter Club home page Giter Club logo

azure-boards-automate-state-transitions's Introduction

Automate State Transitions CI

Azure Boards - Automate State Transitions

This project was created to help automate the updating of parent state transitions depending on the state of the child work items.

This API receives an Azure Boards work item update web hook event. The API will load the work item, check against a series of rules, and update it's parent work item accordingly.

For example, if your User Story is New and you create a task and set that task to active, the User Story should automatically be set to Active.

Setup

  1. Create a new Azure DevOps Personal Access Token

  2. Include the Personal Access Token into the appsettings.json file

     "AppSettings": {
     "PersonalAccessToken": "<personal access token>",
     "Organization": "",
     "SourceForRules": "https://raw.githubusercontent.com/microsoft/azure-boards-automate-state-transitions/master/src/AutoStateTransitions/Rules/"
    
  3. Deploy the project so that it is available from the Azure DevOps instance. Be sure to check if DotNetCore 3 is available (either by using the Azure WebApp Extension, or by deploying it with the package (see blog on self-contained ))

  4. Create a new web hook for the child work item types. In this example we are just setting up web hooks for when Task work items are updated. The web hook should send when the state field is changed.

Populate the URL Field with the url from the deployed instance carried out in previous step along with /api/receiver/webhook/workitem/update appened.

  1. Update the rules in the JSON configuration file for each child work item type. In this example we are going to update the Task (rule.task.json). You will need an entry for each state.

    {
      "type": "Task",
      "rules": [
         {
           "ifChildState": "Active",
           "notParentStates": [ "Active", "Resolved" ],
           "setParentStateTo": "Active",
           "allChildren": false
          },
          {
           "ifChildState": "New",
           "notParentStates": [ "Active", "Resolved", "New" ],
           "setParentStateTo": "Active",
           "allChildren": false
          },
          {
           "ifChildState": "Closed",
           "notParentStates": [],
           "setParentStateTo": "Closed",
           "allChildren": true
         }
       ]
     }
    

    ifChildStates: If the the work item status is this

    notParentStates: If the parent state is not one of these

    setParentStateTo: Then set the parent state to this

    allChildren: If true, then all child items need to be this state to update the parent

    Example 1

    User Story is set to New and it has 4 Tasks that are also new. As soon as a task is set to "Active" then set the User Story to "Active".

    {
      "ifChildState": "Active",
      "notParentStates": [ "Active", "Resolved" ],
      "setParentStateTo": "Active",
      "allChildren": false
    },
    

    Example 2

    If User Story is "Active" and all the child Tasks are set to "Closed". Then lets set the User Story to "Closed"

    {
     "ifChildState": "Closed",
     "notParentStates": [],
     "setParentStateTo": "Closed",
     "allChildren": false
    },
    
  2. Point to the correct url for your rules files. By default the rules files are stored in this location. You can edit the location in the appsettings.json file.

    "AppSettings": {
    "PersonalAccessToken": "<personal access token>",
    "Organization": "",
    "SourceForRules": "https://raw.githubusercontent.com/microsoft/azure-boards-automate-state-transitions/master/src/AutoStateTransitions/Rules/"
    

    Note: Rule files have only been setup for User Story and Task.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

azure-boards-automate-state-transitions's People

Contributors

antoinega avatar danhellem avatar jonmorleyjones avatar microsoftopensource avatar msftgits avatar tomaustin700 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-boards-automate-state-transitions's Issues

Internal Server Error (500)

I followed the setup instructions but keep getting an "Internal Server Error (500)" when testing the service hook:

Failed
Sent at: Wednesday, 30. October 2019 15:35:09
Message
Bug #5 (Some great new idea!) updated by Jamal Hartnett.
Error Message
Internal Server Error (500)

Any ideas what I'm doing wrong?

Unable to resolve service for type 'System.Net.Http.HttpClient' while attempting to activate 'AutoStateTransitions.Repos.RulesRepo

I am seeing the error when i was trying to perform the state transition of work items. Any help much appreciated.

fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HM1044M00JDQ", Request id "0HM1044M00JDQ:00000001": An unhandled exception was thrown by the application.
System.InvalidOperationException: Unable to resolve service for type 'System.Net.Http.HttpClient' while attempting to activate 'AutoStateTransitions.Repos.RulesRepo'.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.<>c__DisplayClass7_0.b__0(Type type)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor(Type serviceType)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
at lambda_method(Closure , IServiceProvider , Object[] )
at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c__DisplayClass4_0.b__0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.g__CreateController|0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Stuck at step 3 deploying

Hello,

I really like the idea and I want to implement it but I'm stuck at step 3:
Deploy the project so that it is available from the Azure DevOps instance.
Where can I find more information about how to do this? (How & Where should I deploy etc)
Thanks in advance!

Kind regards.

App does not launch in visual studio code

Steps to Replicate

  1. Clone the project
  2. Open in visual studio code version 1.46
  3. Select run from the debug view

The launch fails with a message that AutoStateTransitions.dll doesn't exist.

HTTP Error 500

Hello,

We have been deploying this but always get HTTP error 500.
Following some tracing, we could identify .Net Exceptions.

w3wp System.InvalidOperationException 1 Unable to resolve service for type 'System.Net.Http.HttpClient' while attempting to activate 'AutoStateTransitions.Repos.RulesRepo'.

We are running Azure App Service with .Net Core 3.1 extension.

Missing vss-extension.json

Could you please include a vss-extension.json manifest that is a starting point for those of us trying to do this for the first time?

Can we write a rule using same code for other conditions

Hello,

For example if state new is selected, in sub states it should only populate values as “New bug” or “reopened” (Sub state is a custom picklist field)
And if state is committed, substate should show “Ready for grooming” or ready for implementation.
If State done is selected then sub state should only show values in the pick like "Fixed" or "Nor a Bug"..

Please help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.