[英]Uncaught ReflectionException: Class request does not exist in Jenkins
I have jenkins up and running on a laravel project.我在 laravel 项目上启动并运行了 jenkins。 It was working normally till some days ago, then some weird error started to pop up.几天前它一直在正常工作,然后开始弹出一些奇怪的错误。
PHP Fatal error: Uncaught ReflectionException: Class request does not exist in /var/lib/jenkins/workspace/Test_fix_changing-jenkinsfile/vendor/laravel/framework/src/Illuminate/Container/Container.php:809
I did some digging on the inte.net, i have cleaned and chmod 777
into my bootstrap/cache
folder also checked my CreatesApplication.php
to make sure i'm importing Kernel from the right place use Illuminate\Contracts\Console\Kernel;
我在 inte.net 上做了一些挖掘,我已经清理并chmod 777
进入我的bootstrap/cache
文件夹还检查了我的CreatesApplication.php
以确保我从正确的地方导入 Kernel use Illuminate\Contracts\Console\Kernel;
everyting seams normal to me.一切接缝对我来说都很正常。 This error show regardless if all tests passes or fail and this is only happening inside jenkins.无论所有测试通过还是失败,都会显示此错误,并且这仅发生在 jenkins 内部。
I'm using Laravel version 7.30 here's my jenkis file.我正在使用 Laravel 版本 7.30 这是我的 jenkis 文件。
pipeline {
agent any
environment {
GIT_COMMIT_SHORT = "a${env.GIT_COMMIT.take(7)}"
DB_DATABASE_AUX = "a${env.GIT_COMMIT.take(7)}"
}
stages {
stage("Build") {
steps {
sh 'cp ../.env .'
sh 'php --version'
sh 'composer install'
sh 'composer --version'
sh 'composer dump-autoload'
sh 'php artisan key:generate'
}
}
stage('Test backend') {
steps {
sh '/usr/bin/php artisan mysql:createdb $GIT_COMMIT_SHORT'
sh '/usr/bin/php artisan clear-compiled'
sh '/usr/bin/php artisan optimize'
sh '/usr/bin/php artisan route:clear'
sh '/usr/bin/php artisan view:clear'
sh '/usr/bin/php artisan cache:clear'
sh 'echo ""DB_DATABASE=${DB_DATABASE_AUX}>> .env'
sh 'chmod 777 bootstrap/cache'
sh '/usr/bin/php artisan config:cache'
sh '/usr/bin/php artisan config:clear'
sh '/usr/bin/php artisan optimize:clear'
sh '/usr/bin/php artisan migrate:fresh'
sh '/usr/bin/php artisan passport:install'
sh '/usr/bin/php vendor/bin/phpunit tests/Unit/ --stop-on-failure'
sh '/usr/bin/php vendor/bin/phpunit tests/Feature/ --stop-on-failure'
}
post {
always {
sh '/usr/bin/php artisan mysql:deletedb $GIT_COMMIT_SHORT'
}
}
}
}
}
Any idea on how to deal with it would be welcome.欢迎任何关于如何处理它的想法。
That error suggests that you're trying to access the request before it's been bound to the service container.该错误表明您在将请求绑定到服务容器之前尝试访问该请求。 This would happen if you're using the request()
helper or Request
facade before a request has been passed to the Http Kernel.如果在将请求传递到 Http Kernel 之前使用request()
帮助程序或Request
facade,就会发生这种情况。
Is it possible that you added new code that may be trying to access the request in your tests before you've run $this->get()
or any other HTTP helper method?在运行$this->get()
或任何其他 HTTP 辅助方法之前,您是否可能添加了可能试图在测试中访问请求的新代码?
In Laravel 7, this is where "request"
is bound to the container and this is where the container is failing (based on your error message).在 Laravel 7 中, 这是"request"
绑定到容器的地方,也是容器失败的地方(根据您的错误消息)。 This means that the container is trying to resolve request
as a class instead of use an instance that's already been bound to that name.这意味着容器正在尝试将request
解析为 class,而不是使用已经绑定到该名称的实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.