How to use env file in pipeline

Yauheni Kisialiou 20 Reputation points
2023-03-22T11:52:56.15+00:00

if some one could help with the problem of .env file in azure pipeline. I saved my .env file in "Secret files" and the pipeline part regarding the Maven goal execution looks like this:

  - task: DownloadSecureFile@1
    inputs:
      secureFile: '.env'

  - task: CopyFiles@2
    inputs:
      SourceFolder: $(Agent.TempDirectory)
      Contents: '**\.env'
      TargetFolder: $(Build.SourcesDirectory)
      cleanTargetFolder: false

  - task: Maven@3
    inputs:
      mavenPomFile: 'pom.xml'
      mavenOptions: '-Xmx3072m'
      javaHomeOption: 'JDKVersion'
      jdkVersionOption: '17'
      jdkArchitectureOption: 'x64'
      publishJUnitResults: true
      testResultsFiles: '**/surefire-reports/TEST-*.xml'
      goals: 'verify'

The DownloadSecureFile@1 and CopyFiles@2 works fine:

found 1 files

 Copying /home/vsts/work/_temp/.env to /home/vsts/work/1/s/.env

But the goal fails, it looks like .env file is not picked up or not seen... If I hardcode variables in the application.yaml and thus avoid using .env then everything works fine...

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
41,969 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.