Skip to content

environment variables are not picked up by task. #1015

Closed
@sostrich

Description

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

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions