huserben / TfsExtensions

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

"Use same source branch as triggered build"/"Use current changeset for the triggered build" doesn't sync to correct commit #40

Closed cdacamar closed 6 years ago

cdacamar commented 6 years ago

Here was the timeline:

  1. CI build was triggered on a commit
  2. CI1 is testing
  3. CI build was triggered on another commit
  4. CI2 is testing
  5. CI1 triggers another build using the commit that triggered CI1
  6. TR1 uses syncs to master at commit of CI2

Any ideas here?

huserben commented 6 years ago

Hi @cdacamar

could you provide me the logs of the TriggerBuildTask of CI1? And maybe on top the logs of the "GetSources" part of the build that should be triggered.

cdacamar commented 6 years ago

Here is the log of CI1 trigger:

2017-12-11T23:06:36.1019096Z ##[section]Starting: Run selfbuild
2017-12-11T23:06:36.1019096Z ==============================================================================
2017-12-11T23:06:36.1019096Z Task         : Trigger Build
2017-12-11T23:06:36.1019096Z Description  : This tasks allows to trigger a new Build (add it to the queue) as part of a Build Definition. It contains as well some conditions that can be applied, for example if the last build of certain definition was successful or not.
2017-12-11T23:06:36.1019096Z Version      : 2.4.3
2017-12-11T23:06:36.1019096Z Author       : Benjamin Huser
2017-12-11T23:06:36.1019096Z Help         : 
2017-12-11T23:06:36.1019096Z ==============================================================================
2017-12-11T23:06:36.5238448Z Using current Team Project Url
2017-12-11T23:06:36.5238448Z Path to Server: https://devdiv.visualstudio.com/DevDiv
2017-12-11T23:06:36.5238448Z Using Personal Access Token
2017-12-11T23:06:36.5238448Z Build shall be triggered for same user that triggered current build: Xiang Fan
2017-12-11T23:06:36.5238448Z Source Version: cf91fbaa75172adc7435caf362e11d6ef07910bb
2017-12-11T23:06:36.5238448Z Triggered Build will use the same source version: cf91fbaa75172adc7435caf362e11d6ef07910bb
2017-12-11T23:06:36.5238448Z Using same branch as source version: refs/heads/master
2017-12-11T23:06:36.5238448Z Will trigger build with following parameters: \"CiBuildDropName\": \"msvc/builds/cibuild_master_20171211.03/x86chk\", \"BuildPlatform\": \"x86\", \"BuildConfiguration\": \"chk\"
2017-12-11T23:06:36.8988950Z Queue new Build for definition cibuild-selfbuild
2017-12-11T23:06:37.6489993Z Queued new Build for definition cibuild-selfbuild: https://devdiv.visualstudio.com/DevDiv/_build/index?buildId=1214086
2017-12-11T23:06:37.6489993Z ##[section]Finishing: Run selfbuild

Log of CI2 trigger:

2017-12-11T23:19:49.2735111Z ##[section]Starting: Run selfbuild
2017-12-11T23:19:49.2735111Z ==============================================================================
2017-12-11T23:19:49.2735111Z Task         : Trigger Build
2017-12-11T23:19:49.2735111Z Description  : This tasks allows to trigger a new Build (add it to the queue) as part of a Build Definition. It contains as well some conditions that can be applied, for example if the last build of certain definition was successful or not.
2017-12-11T23:19:49.2735111Z Version      : 2.4.3
2017-12-11T23:19:49.2735111Z Author       : Benjamin Huser
2017-12-11T23:19:49.2735111Z Help         : 
2017-12-11T23:19:49.2735111Z ==============================================================================
2017-12-11T23:19:49.7110497Z Using current Team Project Url
2017-12-11T23:19:49.7110497Z Path to Server: https://devdiv.visualstudio.com/DevDiv
2017-12-11T23:19:49.7110497Z Using Personal Access Token
2017-12-11T23:19:49.7110497Z Build shall be triggered for same user that triggered current build: Eric Brumer
2017-12-11T23:19:49.7110497Z Source Version: 03aa728c4d4bb19a3534b7681e6ca8a175fa291b
2017-12-11T23:19:49.7110497Z Triggered Build will use the same source version: 03aa728c4d4bb19a3534b7681e6ca8a175fa291b
2017-12-11T23:19:49.7110497Z Using same branch as source version: refs/heads/master
2017-12-11T23:19:49.7110497Z Will trigger build with following parameters: \"CiBuildDropName\": \"msvc/builds/cibuild_master_20171211.04/x86chk\", \"BuildPlatform\": \"x86\", \"BuildConfiguration\": \"chk\"
2017-12-11T23:19:50.0860827Z Queue new Build for definition cibuild-selfbuild
2017-12-11T23:19:50.7892697Z Queued new Build for definition cibuild-selfbuild: https://devdiv.visualstudio.com/DevDiv/_build/index?buildId=1214134
2017-12-11T23:19:50.8048965Z ##[section]Finishing: Run selfbuild

TR1 "Get Sources" step (tail):

2017-12-11T23:07:06.3202443Z ##[command]git checkout --progress --force 03aa728c4d4bb19a3534b7681e6ca8a175fa291b
2017-12-11T23:07:08.1486179Z Previous HEAD position was 8e42d4d71c... Merged PR 97738: Merge dev/prjoseph/qa_suites_pass_rate to master
2017-12-11T23:07:08.1486179Z HEAD is now at 03aa728c4d... Merged PR 97879: Contest update
2017-12-11T23:07:08.1642455Z ##[command]git config http.https://devdiv.visualstudio.com/DevDiv/_git/msvc.extraheader "AUTHORIZATION: bearer ********"
2017-12-11T23:07:08.1955211Z ##[section]Finishing: Get Sources

Notice the head position got synced to the head of CI2.

huserben commented 6 years ago

so, just for me to fully understand, you trigger twice the same build with different commits (more or less in parallel) but both triggered builds will use the same source version?

cdacamar commented 6 years ago

Yes, that is correct. We have a CI build definition trigger whenever a commit is made to our prod branch.

huserben commented 6 years ago

ok, thanks for the clarification.

I need to set this up on my environment to investigate more in detail, which might take a bit. I for sure will not get to it before the weekend.

huserben commented 6 years ago

Hi again

I just found the cause - there was some strange check in the service that triggeres the build that caused that the actual source version is not passed to the triggerd build, which means it will always use the latest version. I fixed the issue, verified on my repository and it now should behave correct. Version 2.4.4 is uploaded and includes the fix.

Please let me know if it works now for you

cdacamar commented 6 years ago

This appears to have been fixed in 2.4.4! Thank you!

Closing issue.

patnolan commented 6 years ago

TFS has just auto updated to version 2.4.4 and it seems this change has broken our production build!

Issue raised here