젠킨스 빌드 오류 (테스트 환경설정 오류)

DragonTiger·2023년 2월 16일
0

젠킨스 빌드시 만난 에러이다.

회사에서 여느때와 같이 dev 푸쉬를 시키고 피크닉을 하나 야무지게 빨아주고있는데?
당연 배포 되었어야 할 dev서버의 swagger의 내용이 전과 같음을 눈치채고 젠킨스로 들어갔다.

찾아보니...

java.lang.IllegalStateException는 Spring Context가 초기화되지 않았을 때 발생한다고한다!!

Caused by: org.springframework.beans.factory.BeanCreationException은 Spring Bean을 생성하는 동안 예외가 발생했음을 나타낸다.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authServiceImpl': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'auth.redirectUrl' in value "${auth.redirectUrl}"

authServiceImpl 로직에서 Redirect 할 경로를 분기처리하려고 환경설정을 해놓았는데

${auth.redirectUrl} 환경 변수에 저장된 값이 없어서 나는 에러였다.

젠킨스 빌드시 테스트코드가 모조리 failed 뜬걸로봐서 테스트코드의 환경설정을 다시보니

application.yml 환경을 기준으로 application-local.yml, application-dev.yml, application-prod.yml
프로파일 별로 분기처리를 해줬는데 테스트환경에서는 우선순위가 test/resource/ 아래의 있는
yml 파일이없다면 main/resource/ 참조하게되는데
application.yml 은 공통의 환경설정만 되어있으니 ${auth.redirectUrl} 변수에 값이 들어가지 않게 되는거 였다..

테스트 환경설정에 ${auth.redirectUrl} 환경변수 값을 넣어주자.

참고로 @PropertySource("classpath:/path/to/properties/file")
이런식으로 프로퍼티소스 어노테이션을 사용하면 위 위치에 있는 프로퍼티 파일을 로드한다고한다.

profile
take the bull by the horns

0개의 댓글