BlueBasher / WorkItemUpdater

Source code for the VSTS WorkItemUpdater build task
MIT License
36 stars 39 forks source link

Not updating multiple Work Items in the same release #66

Open jwar-gilson opened 4 years ago

jwar-gilson commented 4 years ago

Can you provide some insight why my WorkItemUpdater is not updating multiple work items but just one every time?

Here are my settings configured: image

Here is the log in VSTS showing one work item being updated. There were TWO work items in the release: image

jwar-gilson commented 4 years ago

Created another Release today that had two related WITs attached. Below is the debug log (minus some sensitive information related to my company/employees (used [BLAH BLAH BLAH])):

Work Items

image

Debug logs

2020-05-29T15:53:38.4913145Z ##[debug]Evaluating: succeeded()
2020-05-29T15:53:38.4914011Z ##[debug]Evaluating succeeded:
2020-05-29T15:53:38.4915063Z ##[debug]=> True
2020-05-29T15:53:38.4915594Z ##[debug]Result: True
2020-05-29T15:53:38.4916143Z ##[section]Starting: WorkItem Updater
2020-05-29T15:53:38.5024779Z ==============================================================================
2020-05-29T15:53:38.5025120Z Task         : WorkItem Updater
2020-05-29T15:53:38.5025422Z Description  : This task adds functionality to update WorkItems during a Build or Release.
2020-05-29T15:53:38.5025741Z Version      : 2.5.797
2020-05-29T15:53:38.5025931Z Author       : Blue Basher
2020-05-29T15:53:38.5026929Z Help         : 
2020-05-29T15:53:38.5027185Z ==============================================================================
2020-05-29T15:53:38.7205577Z ##[debug]agent.TempDirectory=d:\a\_temp
2020-05-29T15:53:38.7238096Z ##[debug]loading inputs and endpoints
2020-05-29T15:53:38.7248568Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2020-05-29T15:53:38.7263417Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2020-05-29T15:53:38.7267135Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2020-05-29T15:53:38.7269968Z ##[debug]loading INPUT_ALLWORKITEMSSINCELASTRELEASE
2020-05-29T15:53:38.7274350Z ##[debug]loading INPUT_ASSIGNEDTO
2020-05-29T15:53:38.7276329Z ##[debug]loading INPUT_BYPASSRULES
2020-05-29T15:53:38.7279812Z ##[debug]loading INPUT_FAILTASKIFNOWORKITEMSAVAILABLE
2020-05-29T15:53:38.7299312Z ##[debug]loading INPUT_LINKBUILD
2020-05-29T15:53:38.7299908Z ##[debug]loading INPUT_UPDATEASSIGNEDTO
2020-05-29T15:53:38.7300343Z ##[debug]loading INPUT_UPDATEASSIGNEDTOWITH
2020-05-29T15:53:38.7300750Z ##[debug]loading INPUT_WORKITEMCURRENTSTATE
2020-05-29T15:53:38.7301136Z ##[debug]loading INPUT_WORKITEMDONE
2020-05-29T15:53:38.7301544Z ##[debug]loading INPUT_WORKITEMKANBANSTATE
2020-05-29T15:53:38.7304116Z ##[debug]loading INPUT_WORKITEMSSOURCE
2020-05-29T15:53:38.7314303Z ##[debug]loading INPUT_WORKITEMTYPE
2020-05-29T15:53:38.7319659Z ##[debug]loading SECRET_AZURE_APP_SERVICE_KUDU_PRODUCTION_PASSWORD
2020-05-29T15:53:38.7326414Z ##[debug]loaded 16
2020-05-29T15:53:38.7350267Z ##[debug]Agent.ProxyUrl=undefined
2020-05-29T15:53:38.7352003Z ##[debug]Agent.CAInfo=undefined
2020-05-29T15:53:38.7352496Z ##[debug]Agent.ClientCert=undefined
2020-05-29T15:53:38.7352898Z ##[debug]Agent.SkipCertValidation=undefined
2020-05-29T15:53:38.9168872Z ##[debug]System.TeamFoundationCollectionUri=https://[BLAH BLAH BLAH.COM]/
2020-05-29T15:53:38.9178872Z ##[debug]SYSTEMVSSCONNECTION auth param AccessToken = ***
2020-05-29T15:53:38.9208207Z ##[debug]Build.BuildId=2797
2020-05-29T15:53:38.9208851Z ##[debug]System.TeamProjectId=[BLAH BLAH BLAH]
2020-05-29T15:53:38.9209331Z ##[debug]Build.RequestedFor=[BLAH BLAH BLAH]
2020-05-29T15:53:38.9213443Z ##[debug]workitemsSource=Build
2020-05-29T15:53:38.9213998Z ##[debug]workitemsSourceQuery=null
2020-05-29T15:53:38.9216450Z ##[debug]allWorkItemsSinceLastRelease=false
2020-05-29T15:53:38.9218841Z ##[debug]workItemType=Bug,User Story
2020-05-29T15:53:38.9219309Z ##[debug]workItemState=null
2020-05-29T15:53:38.9220610Z ##[debug]workItemCurrentState=Active
2020-05-29T15:53:38.9221079Z ##[debug]workItemKanbanLane=null
2020-05-29T15:53:38.9297108Z ##[debug]workItemKanbanState=Test
2020-05-29T15:53:38.9298066Z ##[debug]workItemDone=false
2020-05-29T15:53:38.9298813Z ##[debug]linkBuild=true
2020-05-29T15:53:38.9299658Z ##[debug]updateAssignedTo=Always
2020-05-29T15:53:38.9300284Z ##[debug]updateAssignedToWith=FixedUser
2020-05-29T15:53:38.9300739Z ##[debug]assignedTo=[BLAH BLAH BLAH]
2020-05-29T15:53:38.9301163Z ##[debug]updateFields=null
2020-05-29T15:53:38.9301571Z ##[debug]bypassRules=false
2020-05-29T15:53:38.9302498Z ##[debug]failTaskIfNoWorkItemsAvailable=false
2020-05-29T15:53:38.9303300Z ##[debug]addTags=null
2020-05-29T15:53:38.9306419Z ##[debug]removeTags=null
2020-05-29T15:53:38.9306890Z ##[debug]Release.ReleaseId=682
2020-05-29T15:53:38.9307667Z ##[debug]Release.DefinitionId=2
2020-05-29T15:53:38.9308277Z ##[debug]Release.DefinitionEnvironmentId=2
2020-05-29T15:53:38.9309091Z ##[debug]BuildId 2797
2020-05-29T15:53:38.9309834Z ##[debug]ProjectId [BLAH BLAH BLAH]
2020-05-29T15:53:38.9310255Z ##[debug]ReleaseId 682
2020-05-29T15:53:38.9310625Z ##[debug]DefinitionId 2
2020-05-29T15:53:38.9310992Z ##[debug]DefinitionEnvironmentId 2
2020-05-29T15:53:38.9311414Z ##[debug]requestedFor [BLAH BLAH BLAH]
2020-05-29T15:53:38.9312195Z ##[debug]workitemsSource Build
2020-05-29T15:53:38.9327528Z ##[debug]workitemsSourceQuery null
2020-05-29T15:53:38.9327981Z ##[debug]allWorkItemsSinceLastRelease false
2020-05-29T15:53:38.9328412Z ##[debug]workItemType Bug,User Story
2020-05-29T15:53:38.9328794Z ##[debug]WorkItemState null
2020-05-29T15:53:38.9329187Z ##[debug]workItemCurrentState Active
2020-05-29T15:53:38.9329617Z ##[debug]updateWorkItemKanbanLane null
2020-05-29T15:53:38.9330025Z ##[debug]WorkItemKanbanState Test
2020-05-29T15:53:38.9330416Z ##[debug]WorkItemDone false
2020-05-29T15:53:38.9330802Z ##[debug]updateAssignedTo Always
2020-05-29T15:53:38.9331192Z ##[debug]updateAssignedToWith FixedUser
2020-05-29T15:53:38.9331703Z ##[debug]assignedTo [BLAH BLAH BLAH]
2020-05-29T15:53:38.9332098Z ##[debug]addTags null
2020-05-29T15:53:38.9332469Z ##[debug]updateFields null
2020-05-29T15:53:38.9332842Z ##[debug]removeTags null
2020-05-29T15:53:38.9333210Z ##[debug]bypassRules false
2020-05-29T15:53:38.9333617Z ##[debug]failTaskIfNoWorkItemsAvailable false
2020-05-29T15:53:38.9334032Z ##[debug]Get WorkItemTrackingApi
2020-05-29T15:53:38.9357212Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9357835Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9358267Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9358722Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9359199Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9359616Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9360042Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9360449Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9360872Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9361287Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9361710Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9362161Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9362574Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9362994Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9363406Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:38.9363850Z (node:2548) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-05-29T15:53:39.1983575Z ##[debug]Get workItemsRefs
2020-05-29T15:53:39.1989193Z Using Build as WorkItem Source
2020-05-29T15:53:39.3905060Z ##[debug]Loop workItemsRefs
2020-05-29T15:53:39.3910558Z ##[debug]Found WorkItemRef: 5056
2020-05-29T15:53:39.6076368Z Found WorkItem: 5056
2020-05-29T15:53:39.6077220Z ##[debug]Using fixed user "[BLAH BLAH BLAH]" as assignedTo.
2020-05-29T15:53:39.6088172Z ##[debug]Updating  WorkItem: 5056
2020-05-29T15:53:39.6088646Z Updating WorkItem 5056
2020-05-29T15:53:39.6091400Z ##[debug]Found KanbanLane: 
2020-05-29T15:53:39.6092734Z ##[debug]Found KanbanColumn: WEF_38DD72CBDD224FAD9E544F9A54C6FFB8_Kanban.Column
2020-05-29T15:53:39.6093526Z ##[debug]Found KanbanColumnDone: WEF_38DD72CBDD224FAD9E544F9A54C6FFB8_Kanban.Column.Done
2020-05-29T15:53:39.6094782Z Patch: /fields/WEF_38DD72CBDD224FAD9E544F9A54C6FFB8_Kanban.Column Test
2020-05-29T15:53:39.6096666Z Linking Build 2797 to WorkItem 5056
2020-05-29T15:53:39.6097350Z Patch: /relations/- [object Object]
2020-05-29T15:53:39.6097724Z Patch: /fields/System.AssignedTo [BLAH BLAH BLAH]
2020-05-29T15:53:39.6098127Z ##[debug]Start UpdateWorkItem
2020-05-29T15:53:40.0544265Z WorkItem 5056 updated
2020-05-29T15:53:40.0545239Z ##[debug]Finished loop workItemsRefs
2020-05-29T15:53:40.0547302Z ##[debug]task result: Succeeded
2020-05-29T15:53:40.0550567Z ##[debug]Processed: ##vso[task.complete result=Succeeded;]
2020-05-29T15:53:40.0640196Z ##[section]Finishing: WorkItem Updater
jwar-gilson commented 4 years ago

@BlueBasher is this still an active project?

BlueBasher commented 4 years ago

Yes it is still active. Currently have very little time though to do any coding on it. Happy to accept any PR though.. ;)

jwar-gilson commented 4 years ago

@BlueBasher looking at this https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/get%20build%20work%20items%20refs?view=azure-devops-rest-5.1

There is a $top optional parameter and it looks like you already merged this into your latest #65 but I am not seeing it in the settings configurations for the extension. Was there a default of 1 before this was merged? Is this going to get published so we can configure it to see if this solves my issue?

BlueBasher commented 4 years ago

You are correct, the Access Token for publishing the extension was expired.. I updated it and the new version should now be available.

jwar-gilson commented 4 years ago

@BlueBasher Ran another release today with 4 work items and got the same results here -https://github.com/BlueBasher/WorkItemUpdater/issues/66#issuecomment-636056005

It only updated one work item and the workItemLimit did not fix the issue I am having.

If I knew how to run this type of project, I would love to submit a PR but never worked with VSTS extensions.

BlueBasher commented 4 years ago

In your screenshot it shows that it compares the release with previous deployment Release-405. Was that your last successful deployment? If so, maybe you need to check this box "Include workitems since previously completed deployment".

jwar-gilson commented 4 years ago

@BlueBasher I checked that box and ran a new release with two work items. None of them updated.


2020-07-09T15:45:13.4239881Z ##[debug]Get WorkItemTrackingApi
2020-07-09T15:45:13.8298863Z ##[debug]Get workItemsRefs
2020-07-09T15:45:13.8307600Z Using Release as WorkItem Source
2020-07-09T15:45:14.2693327Z ##[debug]Using Release 704 as BaseRelease for 712
2020-07-09T15:45:14.4568377Z No workitems found to update.
2020-07-09T15:45:14.4569590Z ##[debug]task result: Succeeded
2020-07-09T15:45:14.4574970Z ##[debug]Processed: ##vso[task.complete result=Succeeded;]
2020-07-09T15:45:14.4691885Z ##[section]Finishing: WorkItem Updater
Quent1L commented 11 months ago

Hi @BlueBasher, I have the same bug as the last two messages. Do you know if this bug has been fixed?

BlueBasher commented 11 months ago

As far as I know there should not be any bug that causes workitems not to be updated. If something is not updated, it could be because of how the task is configured. If the task is running in a Release Pipeline, often the checkbox "Include workitems since previously completed releases" needs to be checked (if that's what you want). DevOps itself shows workitems in the Release view based on the curernt release in comparison with the last successful Release for that specific Release Stage.

Quent1L commented 11 months ago

Thanks @BlueBasher for your quick reply!

I'm trying to use your extension with Azure yaml pipelines like this :

   task: WorkItemUpdater@3
    displayName: "WorkItem Updater"
    inputs:
      workitemsSource: Build
      workItemType: Task
      updateAssignedTo: Never
      linkBuild: true
      comment: "TEST"
    continueOnError: true

When I launch my pipeline, the work item is recognised by azure but not by WorkItemUpdater : image

##[debug]Get WorkItemTrackingApi
##[debug]Get workItemsRefs
Using Build as WorkItem Source
No workitems found to update.
##[debug]task result: Succeeded

Do you know why it doesn't work? Have I forgotten something?

bhav-rach commented 2 months ago

@BlueBasher I am getting the same issue now. It was working earlier. I get the "No workitems found to update." in the logs. I applied Filter as well.

NikolayBieliashov commented 1 month ago

I have this situation. Have two separate task form deploy 1 and 2 artifacts, each has it's own Workitem Updater Task. I need to tag all work items in release. image Only tasks from the first artifacts were tagged, however, everything was linked properly. I deploy not all artifacts every time though.

PaulARoy commented 1 month ago

Hi, I encounter the same issue and I found why.

TLDR:getReleaseWorkItems only fetches the items of the main artifact

Source is here getReleaseWorkItemsRefs(project: string, releaseId: number, baseReleaseId?: number, top?: number, artifactAlias?: string): Promise<ReleaseInterfaces.ReleaseWorkItemRef[]>; https://github.com/microsoft/azure-devops-node-api/blob/efcb995db93fc08d6e0e731ce9ca76e9747723a7/api/ReleaseApi.ts#L109

By using it here without specifying the artifact https://github.com/BlueBasher/WorkItemUpdater/blob/8d258ef9d80ad01eb7cd7dd4b21a77b0d76e3eb6/src/WorkItemUpdater.ts#L194

We are only fetching the items related to the main one. It really isn't well documented and I had to explore myself the REST api to draw that conclusion.

The fix would be to loop on each artifact-alias of the release, maybe with getAgentArtifactDefinitions(project: string, releaseId: number): Promise<ReleaseInterfaces.AgentArtifactDefinition[]>; https://github.com/microsoft/azure-devops-node-api/blob/efcb995db93fc08d6e0e731ce9ca76e9747723a7/api/ReleaseApi.ts#L22

I did it with a hardcoded artifact-list on a powershell script at the moment.

NikolayBieliashov commented 1 month ago

Hello, Thank you very much for answering my questions! Power shell forever 😊

Mykola Bieliashov DevOps Engineer @.**@.> +380504846811 techfabric.com

@.***

This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, notify the sender immediately by return email and delete the message and any attachments from your system.

From: Paul Roy @.> Sent: Tuesday, September 24, 2024 4:11 PM To: BlueBasher/WorkItemUpdater @.> Cc: Nikolay Bieliashov @.>; Comment @.> Subject: Re: [BlueBasher/WorkItemUpdater] Not updating multiple Work Items in the same release (#66)

Hi, I encounter the same issue and I found why.

TLDR:getReleaseWorkItems only fetches the items of the main artifact

Source is here getReleaseWorkItemsRefs(project: string, releaseId: number, baseReleaseId?: number, top?: number, artifactAlias?: string): Promise<ReleaseInterfaces.ReleaseWorkItemRef[]>; https://github.com/microsoft/azure-devops-node-api/blob/efcb995db93fc08d6e0e731ce9ca76e9747723a7/api/ReleaseApi.ts#L109

By using it here without specifying the artifact https://github.com/BlueBasher/WorkItemUpdater/blob/8d258ef9d80ad01eb7cd7dd4b21a77b0d76e3eb6/src/WorkItemUpdater.ts#L194

We are only fetching the items related to the main one. It really isn't well documented and I had to explore myself the REST api to draw that conclusion.

The fix would be to loop on each artifact-alias of the release, maybe with getAgentArtifactDefinitions(project: string, releaseId: number): Promise<ReleaseInterfaces.AgentArtifactDefinition[]>; https://github.com/microsoft/azure-devops-node-api/blob/efcb995db93fc08d6e0e731ce9ca76e9747723a7/api/ReleaseApi.ts#L22

This is what I did with a powershell script at the moment.

— Reply to this email directly, view it on GitHubhttps://github.com/BlueBasher/WorkItemUpdater/issues/66#issuecomment-2371232883, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWQYT6BRNOMEPNBLMQLIPUDZYFQGVAVCNFSM6AAAAABMOJKRMCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZRGIZTEOBYGM. You are receiving this because you commented.Message ID: @.***>