taste-zzip / taste.zip.server

1 stars 0 forks source link

[Error] Build Fail on Jenkins Server #3

Closed devrokket closed 5 months ago

devrokket commented 5 months ago

Describe

After hiding yml files with .gitignore, build failed at Jenkins pipeline.

Problem

image
TasteZipApplicationTests > contextLoads() FAILED
    java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:143
        Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:794
            Caused by: org.springframework.beans.factory.BeanCreationException at ConstructorResolver.java:647
                Caused by: org.springframework.beans.BeanInstantiationException at SimpleInstantiationStrategy.java:171
                    Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException at DataSourceProperties.java:186

1 test completed, 1 failed

> Task :test FAILED

FAILURE: Build failed with an exception.

Build fail message: couldn't read datasource properties in yml files

Idea

In this time, We will use Dockerhub private repository. cause I want to be familiar with Docker.

devrokket commented 5 months ago

Jenkins-credential로 yml 파일을 등록해서 같이 빌드할 수 있는 방법으로 진행.

devrokket commented 5 months ago

Jenkins jobs가 고도화 됨에 따라, 기존 freestyle 형식으로 작성된 item이 한계가 있음. pipeline 문법으로 migration 필요. Converter plugin이 github hook trigger, Discord Notifiler, send over SSH는 지원하지 않아서, convert 된 파이프라인에 추가 작업 필요.

devrokket commented 5 months ago
image

docker exec으로 내부 실행해서 spring boot application아 저장되어 있는 경로 탐색

docker 내부 jenkins item 위치 /var/jenkins_home/workspace/tastezip-cicd

devrokket commented 5 months ago

pipeline 내부 현재 경로

image
devrokket commented 5 months ago

쉘 스크립트에서는 - 기호가 변수 이름에 사용되지 않는다. 변수 이름 _으로 하니까 빌드 성공함.

stage('secret.yml download') {
            steps {
                withCredentials([file(credentialsId: 'application-test', variable: 'application_test')]) {
                    script {
                        sh 'cp ${application_test} ./src/main/resources/application-test.yml'
                    }
                }
            }
        }
devrokket commented 5 months ago

이전 성공. 기존의 tastezip-cicd-pipeline item 삭제

devrokket commented 5 months ago

++ application.yml 이름을 credential에서 application-test.yml로 대체하여 사용