IsRunningOnAzurePipelines doesn't work for Ubuntu #3149
-
What You Are Seeing?IsRunningOnAzurePipelines returns false What is Expected?IsRunningOnAzurePipelines returns true What version of Cake are you using?Are you running on a 32 or 64 bit system?What environment are you running on? Windows? Linux? Mac?Linux Are you running on a CI Server? If so, which one?Azure Pipelines How Did You Get This To Happen? (Steps to Reproduce)https://cakebuild.net/docs/integrations/build-systems/azure-pipelines/
Output LogNothing |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
@matt40k This is by design. Docs: public bool IsRunningOnAzurePipelines
=> !string.IsNullOrWhiteSpace(_environment.GetEnvironmentVariable("TF_BUILD")) && !IsHostedAgent; // <#<#<#
public bool IsRunningOnAzurePipelinesHosted
=> !string.IsNullOrWhiteSpace(_environment.GetEnvironmentVariable("TF_BUILD")) && IsHostedAgent; // <#<#<# |
Beta Was this translation helpful? Give feedback.
-
What was the name of the agent running the build? The check tests for existence of |
Beta Was this translation helpful? Give feedback.
-
@augustoproiete This isn't hosted, its just the cloud using the ubuntu-latest image - https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml @pascalberger Just using the marketplace Cake - https://cakebuild.net/docs/integrations/build-systems/azure-pipelines/azure-devops-build-task-extension - reports:
|
Beta Was this translation helpful? Give feedback.
-
@matt40k You tricked me with "Ubuntu hosted" in the title 😄. I see that you changed the title now. Can you inspect the environment variables to see what is in there? We're particularly interested in the build.cake var envVars = EnvironmentVariables();
Information("Environment Variables: ");
foreach(var envVar in envVars)
{
Information("Key: {0}\tValue: \"{1}\"", envVar.Key, envVar.Value);
} |
Beta Was this translation helpful? Give feedback.
-
@matt40k My question was not about the task used but what was the name of the agent which run the job: |
Beta Was this translation helpful? Give feedback.
-
If you're running on hosted pool you need to call
public bool IsRunningOnAzurePipelines
=> !string.IsNullOrWhiteSpace(_environment.GetEnvironmentVariable("TF_BUILD")) && !IsHostedAgent;
public bool IsRunningOnAzurePipelinesHosted
=> !string.IsNullOrWhiteSpace(_environment.GetEnvironmentVariable("TF_BUILD")) && IsHostedAgent; |
Beta Was this translation helpful? Give feedback.
-
So Cake is picking up the Linux Microsoft hosted pool as self-hosted? |
Beta Was this translation helpful? Give feedback.
-
Everything as expected. See #3148 (comment). It has nothing to do with Linux. If you want to know if you run on a Azure Pipelines hosted pool you need to run
|
Beta Was this translation helpful? Give feedback.
If you're running on hosted pool you need to call
IsRunningOnAzurePipelinesHosted
notIsRunningOnAzurePipelinesHosted
.IsRunningOnAzurePipelines
is defined as:IsRunningOnAzurePipelinesHosted
is defined as: