While working on a Spring Boot 3.2.2 project, I am creating a pipeline using GitHub Actions. There are multiple versions of yml files and environment variables are managed through .env. There are two libraries used: implementation("io.github.cdimascio:dotenv-java:3.0.0") implementation("me.paulschwarz:spring-dotenv:4.0.0") The problem occurs during build testing during the CI/CD process.
Create and check the .env file through the following process.
- name: .env
run: |
jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <<< "$SECRETS_CONTEXT" > ./src/main/resources/.env
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
- name: .env
run: |
echo ".env file location: "
ls -l ./src/main/resources/.env
cat ./src/main/resources/.env
This is a content image printed with cat. enter image description here
Execution stops with this error.
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:180
Caused by: io.github.cdimascio.dotenv.DotenvException at DotenvParser.java:76
I encountered this error once before, and when I checked the DotenvParser section, I assumed it was caused by failing to read environment variables and solved it by adding the cdimascio library. However, it appears that it has not been resolved as it has occurred again. I've searched for several problems, but I don't know what to do. It would be possible to manually set environment variables one by one, but I want a better way. *In Local, those two libraries ran fine without any conflicts.