3

I have 2 repo, source and target for source there are 2 stages in the release pipeline . one is building the artifacts called Dev and then another is trigger => trigger the build pipeline for the target repo using api call. Both repos are in the same project.

It can be possible that target repo can be run manually run without continuous CI of source-repo. Now my question is there any possibility to figure out how the build of target-repo initiated is it manually or CI?

AzDo Pipeline

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
change198
  • 1,647
  • 3
  • 21
  • 60

1 Answers1

4

You have variable Build.Reason which gives you

The event that caused the build to run.

enter image description here

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
  • I know this should be the case, but for me when I checked I see buildReason in `target-repo` it shows `Manual`. Is it because I clicked manually the release of `Dev` stage from the source repo? – change198 Nov 20 '20 at 07:29
  • This is probably because there is no difference between clicking on the UI and running through API. At the end all calls are manual. What you can do is to create a variable on the pipeline and set it to default like UI, and change it triggering to API when you call API. In combination with Build.Reason you should get what you want. – Krzysztof Madej Nov 20 '20 at 08:53
  • If I understood correctly, I think I can do that one and during the API call, I can update that release value. But apart from this let say I created a variable after the end of API call in my release of `trigger` now how can I access this output variable in my build of target-repo. e.g. `echo "1.2.3" >> $(System.ArtifactsDirectory)/version.env` now how can I download this `version.env` in my build process of `target`. – change198 Nov 20 '20 at 13:23
  • Do you use Release pipelines or YAML pipelines? And if you want to share a vriable between two pipelines this won't be easy. You can save variable as an artifact and then use this artifact in your target pipeline to recreate variable using logging command. Basically you need make an artifact for `version.env` and download it in your next pipeline. – Krzysztof Madej Nov 20 '20 at 13:49