0
Follow
2
View

Jenkinsfile - spin up laravel by docker-compose and run tests?

dingashuai 注册会员
2023-01-26 03:59

When you run docker-compose up, it will spawn a container for each service defined in your docker-compose.yml file. If you put sh 'php artisan make:test UserTest' in your Jenkins file, it will not execute your command in a container, so you won't have access to your dev/test environment.
Instead, you will need a testing image : a Dockerfile with php installed, and your tests file copied into it, so that you can set its CMD to php artisan make:test UserTest, which will get executed when a container is created from the image built from the Dockerfile.
Then, either add it to your Compose services, or start it explicitly with docker run testing_image. Then check its exit code, stdout/stderr, files produced to determine how the tests went.

About the Author

Question Info

Publish Time
2023-01-26 03:59
Update Time
2023-01-26 03:59