繁体   English   中英

Bash 命令在终端运行,但不在 Jenkins/Bash 脚本中运行

[英]Bash commands run at terminal but not in Jenkins/Bash Script

我在 Jenkins 中有一个 Symfony 项目
当我运行命令php bin/console doctrine:fixtures:load --fixtures=tests/Fixtures/TestFixtures.php --env=test --no-interaction它直接在终端中工作正常,但它在 Jenkins 中不起作用!
这是Jenkinsfile

pipeline{
    agent any
    stages {
        stage('Build'){
            steps{
                sh 'php composer.phar install --no-interaction'
            }
        }
        stage('Tests'){
            steps{
                sh 'php bin/console doctrine:schema:drop --force --env=test'
                sh 'php bin/console doctrine:schema:update --force --env=test'
                sh 'php bin/console doctrine:fixtures:load --fixtures=tests/Fixtures/TestFixtures.php --env=test --no-interaction'
                sh 'php vendor/phpunit/phpunit/phpunit'
            }
        }
    }
}

我收到这个错误:

In LoadDataFixturesDoctrineCommand.php line 109:

  Could not find any fixtures to load in:   

  - tests/Fixtures/TestFixtures.php 

我在这里错过了什么?

管道跟踪:

[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] sh
+ php composer.phar install --no-interaction
Content-type: text/html; charset=UTF-8

Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Package operations: 103 installs, 0 updates, 0 removals
  - Installing ocramius/package-versions (1.4.2): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.13.1): Loading from cache
  - Installing symfony/polyfill-ctype (v1.13.1): Loading from cache
  - Installing twig/twig (v2.12.3): Loading from cache
  - Installing paragonie/random_compat (v2.0.18): Loading from cache
  - Installing symfony/polyfill-php70 (v1.13.1): Loading from cache
  - Installing symfony/polyfill-util (v1.13.1): Loading from cache
  - Installing symfony/polyfill-php56 (v1.13.1): Loading from cache
  - Installing symfony/symfony (v3.4.36): Loading from cache
  - Installing symfony/polyfill-intl-icu (v1.13.1): Loading from cache
  - Installing symfony/polyfill-apcu (v1.13.1): Loading from cache
  - Installing psr/simple-cache (1.0.1): Loading from cache
  - Installing psr/log (1.1.2): Loading from cache
  - Installing psr/link (1.0.0): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing psr/cache (1.0.1): Loading from cache
  - Installing fig/link-util (1.1.0): Loading from cache
  - Installing doctrine/lexer (1.2.0): Loading from cache
  - Installing doctrine/annotations (v1.8.0): Loading from cache
  - Installing doctrine/reflection (v1.0.0): Loading from cache
  - Installing doctrine/event-manager (1.1.0): Loading from cache
  - Installing doctrine/collections (1.6.4): Loading from cache
  - Installing doctrine/cache (1.10.0): Loading from cache
  - Installing doctrine/persistence (1.3.3): Loading from cache
  - Installing doctrine/inflector (1.3.1): Loading from cache
  - Installing doctrine/common (v2.11.0): Loading from cache
  - Installing doctrine/instantiator (1.3.0): Loading from cache
  - Installing doctrine/dbal (v2.10.0): Loading from cache
  - Installing doctrine/orm (v2.7.0): Loading from cache
  - Installing beberlei/doctrineextensions (v1.2.6): Loading from cache
  - Installing doctrine/doctrine-cache-bundle (1.4.0): Loading from cache
  - Installing friendsofsymfony/user-bundle (v2.0.2): Loading from cache
  - Installing incenteev/composer-parameter-handler (v2.1.4): Loading from cache
  - Installing isom/code-maker (dev-master a5508f4): Cloning a5508f44af from cache
  - Installing jdorn/sql-formatter (v1.2.17): Loading from cache
  - Installing paragonie/sodium_compat (v1.12.2): Loading from cache
  - Installing pusher/pusher-php-server (v3.4.1): Loading from cache
  - Installing mrad/notifications-bundle (v1.3.0): Loading from cache
  - Installing phenx/php-font-lib (0.5.1): Loading from cache
  - Installing sabberworm/php-css-parser (8.3.0): Loading from cache
  - Installing phenx/php-svg-lib (v0.3.3): Loading from cache
  - Installing dompdf/dompdf (v0.8.3): Loading from cache
  - Installing sbc/auto-reporting-bundle (dev-master 4cd6866): Cloning 4cd68660b5 from cache
  - Installing symfony/polyfill-php72 (v1.13.1): Loading from cache
  - Installing symfony/polyfill-intl-idn (v1.13.1): Loading from cache
  - Installing symfony/mime (v5.0.2): Loading from cache
  - Installing symfony/service-contracts (v2.0.1): Loading from cache
  - Installing symfony/polyfill-php73 (v1.13.1): Loading from cache
  - Installing symfony/http-client-contracts (v2.0.1): Loading from cache
  - Installing symfony/http-client (v5.0.2): Loading from cache
  - Installing sensiolabs/security-checker (v6.0.3): Loading from cache
  - Installing sensio/distribution-bundle (v5.0.25): Loading from cache
  - Installing sensio/framework-extra-bundle (v3.0.29): Loading from cache
  - Installing slimen/log-tracker (v1.3.1): Loading from cache
  - Installing behat/transliterator (v1.2.0): Loading from cache
  - Installing gedmo/doctrine-extensions (v2.4.38): Loading from cache
  - Installing stof/doctrine-extensions-bundle (v1.3.0): Loading from cache
  paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
symfony/polyfill-intl-icu suggests installing ext-intl (For best performance)
doctrine/cache suggests installing alcaeus/mongo-php-adapter (Required to use legacy MongoDB driver)
doctrine/doctrine-cache-bundle suggests installing symfony/security-acl (For using this bundle to cache ACLs)
paragonie/sodium_compat suggests installing ext-libsodium (PHP < 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security.)
paragonie/sodium_compat suggests installing ext-sodium (PHP >= 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security.)
dompdf/dompdf suggests installing ext-gmagick (Improves image processing performance)
dompdf/dompdf suggests installing ext-imagick (Improves image processing performance)
symfony/polyfill-intl-idn suggests installing ext-intl (For best performance)
symfony/service-contracts suggests installing symfony/service-implementation
sensio/framework-extra-bundle suggests installing symfony/psr-http-message-bridge (To use the PSR-7 converters)
gedmo/doctrine-extensions suggests installing doctrine/mongodb-odm (to use the extensions with the MongoDB ODM)
stof/doctrine-extensions-bundle suggests installing doctrine/mongodb-odm-bundle (to use the MongoDB ODM extensions)
kriswallsmith/assetic suggests installing leafo/lessphp (Assetic provides the integration with the lessphp LESS compiler)
kriswallsmith/assetic suggests installing leafo/scssphp (Assetic provides the integration with the scssphp SCSS compiler)
kriswallsmith/assetic suggests installing leafo/scssphp-compass (Assetic provides the integration with the SCSS compass plugin)
kriswallsmith/assetic suggests installing patchwork/jsqueeze (Assetic provides the integration with the JSqueeze JavaScript compressor)
kriswallsmith/assetic suggests installing ptachoire/cssembed (Assetic provides the integration with phpcssembed to embed data uris)
symfony/assetic-bundle suggests installing kriswallsmith/spork (to be able to dump assets in parallel)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
vich/uploader-bundle suggests installing doctrine/mongodb-odm-bundle (For integration with Doctrine ODM)
vich/uploader-bundle suggests installing doctrine/phpcr-odm (For integration with Doctrine PHPCR)
vich/uploader-bundle suggests installing knplabs/knp-gaufrette-bundle (For integration with Gaufrette)
vich/uploader-bundle suggests installing liip/imagine-bundle (To generate image thumbnails)
vich/uploader-bundle suggests installing oneup/flysystem-bundle (For integration with Flysystem)
vich/uploader-bundle suggests installing willdurand/propel-eventdispatcher-bundle (For integration with Propel)
doctrine/data-fixtures suggests installing alcaeus/mongo-php-adapter (For using MongoDB ODM with PHP 7)
doctrine/data-fixtures suggests installing doctrine/mongodb-odm (For loading MongoDB ODM fixtures)
doctrine/data-fixtures suggests installing doctrine/phpcr-odm (For loading PHPCR ODM fixtures)
zendframework/zend-eventmanager suggests installing container-interop/container-interop (^1.1.0, to use the lazy listeners feature)
zendframework/zend-eventmanager suggests installing zendframework/zend-stdlib (^2.7.3 || ^3.0, to use the FilterChain feature)
zendframework/zend-code suggests installing zendframework/zend-stdlib (Zend\Stdlib component)
ocramius/proxy-manager suggests installing ocramius/generated-hydrator (To have very fast object to array to object conversion for ghost objects)
ocramius/proxy-manager suggests installing zendframework/zend-json (To have the JsonRpc adapter (Remote Object feature))
ocramius/proxy-manager suggests installing zendframework/zend-soap (To have the Soap adapter (Remote Object feature))
ocramius/proxy-manager suggests installing zendframework/zend-xmlrpc (To have the XmlRpc adapter (Remote Object feature))
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.7.2)
phpunit/phpunit suggests installing ext-soap (*)
phpunit/phpunit suggests installing ext-xdebug (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0.0)
symfony/phpunit-bridge suggests installing symfony/error-handler (For tracking deprecated interfaces usages at runtime with DebugClassLoader)
Package symfony/assetic-bundle is abandoned, you should avoid using it. Use symfony/webpack-encore-pack instead.
Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.
Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.
Package sensio/generator-bundle is abandoned, you should avoid using it. Use symfony/maker-bundle instead.
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Creating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
 // Clearing the cache for the dev environment with debug                       
 // true                                                                        

 [OK] Cache for the "dev" environment (debug=true) was successfully cleared.    

> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets
 Trying to install assets as relative symbolic links.

 --- ------------------ ------------------ 
      Bundle             Method / Error    
 --- ------------------ ------------------ 
  ✔   TiersBundle        relative symlink  
  ✔   LogTrackerBundle   relative symlink  
  ✔   CodeMakerBundle    relative symlink  
 --- ------------------ ------------------ 

 [OK] All assets were successfully installed.                                   

> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Tests)
[Pipeline] sh
+ php bin/console doctrine:schema:drop --force --env=test
 Dropping database schema...

 [OK] Database schema dropped successfully!                                     

Content-type: text/html; charset=UTF-8

[Pipeline] sh
+ php bin/console doctrine:schema:update --force --env=test
 Updating database schema...

     82 queries were executed

 [OK] Database schema updated successfully!                                     

Content-type: text/html; charset=UTF-8

[Pipeline] sh
+ php bin/console doctrine:fixtures:load --fixtures=./tests/Fixtures/TestFixtures.php --env=test --no-interaction

In LoadDataFixturesDoctrineCommand.php line 109:

  Could not find any fixtures to load in:   

  - ./tests/Fixtures/TestFixtures.php       


doctrine:fixtures:load [--fixtures [FIXTURES]] [--append] [--em EM] [--shard SHARD] [--purge-with-truncate] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

Content-type: text/html; charset=UTF-8

[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] mail
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

你没有给出二进制文件的完整路径..

在终端路径是从配置文件中获取的,但是每当您在脚本中使用时,您都必须提供二进制文件的完整路径。

例如 /usr/local/bin 像这样

尝试文件的绝对路径 --fixtures=tests/Fixtures/TestFixtures.php 或者如果您在本地的 windows env 上,请检查文件名大小写敏感度

检查 service.yaml,“排除:'../src/{......}'”部分。 可能是“夹具目录”被排除在自动连线/自动配置之外。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM