Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

environment variables are not picked up by task. #1015

Closed
sostrich opened this issue Jan 30, 2024 · 4 comments
Closed

environment variables are not picked up by task. #1015

sostrich opened this issue Jan 30, 2024 · 4 comments
Assignees

Comments

@sostrich
Copy link

Please check our current Issues to see if someone already reported this https://github.com/Microsoft/azure-pipelines-task-lib/issues

Environment

azure-pipelines-task-lib version: The one used by Azure Devops 2022.01

Issue Description

Some ADOS tasks (like PublishCodeCoverageResults@2) cannot be influenced by environment variables, because they pass env variables (e.g. here) and then task-lib does not pick up other existing environment variables.

Expected behaviour

Existing environment variables should not be lost when other, unrelated environment variables are passed explicitly by ADOS tasks.

Actual behaviour

The existing environment variables are lost as soon as any env variables are passed.

Steps to reproduce

e.g. ADOS task PublishCodeCoverageResults@2 is affected. It fails when run in a container that does not have the ICU libs, and outputs the message:
"Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu (or icu-libs) using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information."

But when the System.Globalization.Invariant flag is set to true via an environment variable, you still get the error.

  1. set an environment variable affecting the task, e.g. SYSTEM_DOTNET_GLOBALIZATION_INVARIANT=1
  2. run the task inside a container that does not have the icu libs
  3. get the error.
   -job:
     - test:
        container: maven:3.8-eclipse-temurin-17
        steps:     
          - task: UseDotNet@2
            displayName: 'Use .NET Core sdk 7.0.x'
            inputs:
              version: 7.0.x
          - bash: |
              echo "##vso[task.setvariable variable=DOTNET_SYSTEM_GLOBALIZATION_INVARIANT]1"
          - bash: |
              echo "$(DOTNET_SYSTEM_GLOBALIZATION_INVARIANT)"
          - task: PublishCodeCoverageResults@2
            inputs:
              codeCoverageTool: JaCoCo
              summaryFileLocation: '$(PATH_TO_jacoco.xml)'
              reportDirectory: '$(PATH_TO_JACOCO_DIR)'
              failIfCoverageEmpty: true
            env:
              DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1

Logs

Starting: PublishCodeCoverageResults
Task : Publish code coverage results v2
Description : Publish any of the code coverage results from a build
Version : 2.225.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/test/publish-code-coverage-results
Found 1 result(s) matching pattern: /__w/7/s/target/coverage/platform-quarkus-projects/jacoco.xml
/__w/7/s/target/coverage/platform-quarkus-projects/jacoco.xml
/__w/_tasks/PublishCodeCoverageResults_2a7ebc54-c13e-490e-81a5-d7561ab7cd97/2.225.0/node_modules/coveragepublisher/CoveragePublisher/linux-x64/CoveragePublisher.Console /__w/7/s/target/path_to_coverage_report --reportDirectory /__w/_temp/3089be52-7065-4c58-98f9-02471876dfa4
Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu (or icu-libs) using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information.

at System.Environment.FailFast(System.String)
at System.Globalization.GlobalizationMode+Settings..cctor()
at System.Globalization.CultureData.CreateCultureWithInvariantData()
at System.Globalization.CultureData.get_Invariant()
at System.Globalization.CultureInfo..cctor()
at System.Globalization.CultureInfo.get_InvariantCulture()
at CommandLine.ParserSettings..ctor()
at CommandLine.Parser+<>c.<.cctor>b__20_0()
at System.Lazy1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ViaFactory(System.Threading.LazyThreadSafetyMode) at System.Lazy1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecutionAndPublication(System.LazyHelper, Boolean)
at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].CreateValue()
at CommandLine.Parser.get_Default()
at Microsoft.Azure.Pipelines.CoveragePublisher.ArgumentsProcessor.ProcessCommandLineArgs(System.String[])
at Microsoft.Azure.Pipelines.CoveragePublisher.Program.Main(System.String[])

Finishing: PublishCodeCoverageResults

@DenisRumyantsev
Copy link
Contributor

Hi @sostrich, I suppose the DOTNET_SYSTEM_GLOBALIZATION_INVARIANT is actually picked up by the PublishCodeCoverageResults task, but does not effect on this task as expected. I suggest you to install the libicu package since the task itself uses this package as a dependency. You can add RUN apt install -y libicu to your Dockerfile.

@sostrich
Copy link
Author

sostrich commented Mar 22, 2024

Hi, thanks for your help! This is not the best solution for us, since we have many dockerfiles which we all have to change. Still, I guess it is an option if the v1 version of the task ever gets removed.

when you say "not effect on this task as expected", do you mean it is expected behaviour that the env variable does not affect the task? Is there a reason why this is intended behaviour?

Copy link

This issue has had no activity in 90 days. Please comment if it is not actually stale

@DenisRumyantsev
Copy link
Contributor

@sostrich fixed, thanks. The DOTNET_SYSTEM_GLOBALIZATION_INVARIANT environment variable will be picked up by the PublishCodeCoverageResults@2 task in the following task version (2.242.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants