vNext build is unable to update workitem integrated in build field for specific branch(es) from team project(s)


hi all,

i've powershell script below update workitem integrated in build field; however, pulling entire team project changes. want pull only change(s) branch(es) is/are mapping in the build workspace. here have.

dev-build (tfs 2017 vnext build)

    workspace mapping 2 different team projects $/teamprojecta/branch1/dev/src , $/teamprojectb/branch3/dev/src

param(      $username,      $password  )    $token = ("{0}:{1}" -f $username, $password)  $tokenbytes = [system.text.encoding]::utf8.getbytes($token)  $authorization = [system.convert]::tobase64string($tokenbytes)  $headers = @{authorization=("basic {0}" -f $authorization)}    [string] $collectionaddress = "$env:system_teamfoundationcollectionuri"  [string] $project = "$env:system_teamproject"  [string] $buildid = "$env:build_buildid"  [string] $buildnumber = "$env:build_buildnumber"    try  {      $workitemaddress = $collectionaddress + $project + "/_apis/build/builds/" + $buildid + "/workitems?api-version=2.0"      write-output "getting work items $workitemaddress"        $response = invoke-restmethod -uri $workitemaddress -contenttype "application/json" -headers $headers -method        $workitemcount = $response.count      $workitemurlarray = $response.value        write-output "$workitemcount work items available update"        for($i = 0; $i -lt $workitemcount ; $i++)      {          write-output "updating item $i build $buildnumber"  $workitemurlarray[$i].url          $body = '[{ "op": "add", "path": "/fields/microsoft.vsts.build.integrationbuild", "value":"' + $buildnumber + '"}]'          write-output $body          $workitemupdateaddress = $workitemurlarray[$i].url + "?api-version=1.0"            invoke-restmethod -uri $workitemupdateaddress -body $body -contenttype "application/json-patch+json" -headers $headers -method patch      }  }  catch  {      write-output $_.exception | format-list -force  }

best regards,

andy pham


best regards, andy pham

hi andypham,

yes, tested in tfs 2015.3, has issue. tfs 2017.1, fix it.

best regards


msdn community support
please remember click "mark answer" responses resolved issue, , click "unmark answer" if not. can beneficial other community members reading thread. if have compliments or complaints msdn support, feel free contact msdnfsf@microsoft.com.



Archived Forums V  >  Team Foundation Server - Build and release management



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........