Search code examples
laraveljenkinsjenkins-pipelinecomposer-phplumen

Running composer install not working with Jenkins in a microservices architecture


I am automating a microservices architecture with a Jenkins pipeline and having this issue although the file composer.json exists in that folder

C:\Program Files (x86)\Jenkins\workspace\C2Project\C2\autority-service>composer update Composer could not find a composer.json file in C:\Program Files (x86)\Jenkins\workspace\C2Project\C2\autority-service To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section

here is the concerned jenkins stage:

 stage('Build autority-service'){ steps { dir('C:\\Program Files (x86)\\Jenkins\\workspace\\C2Project\\C2\\autority-service') {
    bat "sudo composer update" 
    bat "sudo composer dump-autoload"
    bat "sudo composer install"
    sh "php artisan key:generate"
    bat "php artisan cache:clear"
    bat "php artisan config:clear"
    bat "php artisan migrate"
    bat "php artisan db:seed" } } }

Can anyone please help me fix this issue?


Solution

  • I resolved this issue by adding a composer.phar file because Jenkins couldn't recognize the composer.json file as they are similar with this command line curl -sS getcomposer.org/installer | php then installed composer on the Jenkins server using the composer.phar file php composer.phar install