Proposal: "IsRunningOnAzurePipelines" behavior change #3589
Replies: 2 comments 1 reply
-
Different people have different use-cases. Current implementation works fine for people which use hosted and on-prem pools and want to do something different. I agree that current properties don't work very well if you run on different CI servers and want to know if you are running on Azure Pipelines, but don't care if agent is running hosted or on-prem. The current naming of
If we use
There are also other issue with build system integration which might need some work or bigger refactoring, but it is not decided yet when this will happen, but for sure not before Cake 3.0. |
Beta Was this translation helpful? Give feedback.
-
This will be tracked with #3654 |
Beta Was this translation helpful? Give feedback.
-
Build System has IsRunningOnAzurePipelines and IsRunningOnAzurePipelinesHosted.
I would like to propose a change to this. Based on what I see from some of the tests, it appears that this used to differentiate between Cloud and On Prem Azure Dev Ops instances.
However, now, IsRunningOnAzurePipelines returns false even if you're running on Azure Pipelines Cloud, based on Environment.Agent.IsHosted.
This results in very counter intuitive interactions to me, because I'm not on an On Prem AzDO instance, and I never will be. But this is returning different values depending on which build pool I'm running. (Some are self-hosted, some aren't.)
IsRunningOnAzurePipelines should return true regardless of the hosted status of my agent, because it's totally irrelevant to the context that the build agent sets up.
In fact, I'm not sure why this API was set up this way, because the Agent should be fundamentally the same, hosted or not. Unless it's somehow still useful for on prem stuff, I think IsRunningOnAzurePipelinesHosted should be deprecated. If I wanted to detect the Environment I was in, I should just be checking Environment Variables. And if I wanted to know if I was hosted, I could just hit Environment.Agent.IsHosted. The value that this API provides is in me not knowing to have to check for "TF_BUILD" in the environment variables.
So even if IsRunningOnAzurePipelinesHosted not deprecated, IsRunningOnAzurePipelines should always return true if the build is running on Azure Pipelines, and !IsHosted should be removed from the check. I mean, it's the obvious semantic meaning of the words "Is Running On Azure Pipelines".
As it is, it's not at all obvious that in order to detect if I'm running on Azure Pipelines, I actually need to put (IsRunningOnAzurePipelines || IsRunningOnAzurePipelinesHosted) everywhere instead of just IsRunningOnAzurePipelines.
This is one of those things that Cake can't check locally, which means that trying to debug it is a real pain.
Beta Was this translation helpful? Give feedback.
All reactions