-1

I have a jenkins job that runs "php ./composer.phar install" and installs required php dependencies from a couple of other git repos that are defined in composer.json file. This job is working fine on current jenkins agent.

Now the requirement is to modify the job to run it on a docker container instead of jenkins agent, after modifying the job it is failing to checkout the git repos where PHP's dependencies are located due to permission issues.

Here is the composer.json file where the git repo(that has php dependencies) is mentioned:

{

"name": "Organization/html_receipts",

"type": "project",

"authors": [

{

"name": "accesso",

"email": "[email protected]"

}

],

"repositories": [

{

"type": "package",

"no-api": true,

"package": {

"name": "Organization/accessoservices-php",

"version": "1.3.39",

"source": {

"url": "[email protected]:Organization/OrganizationServices-PHP",

"type": "git",

"reference": "tags/1.3.39"

}

}

},

Here is the error I'm getting in jenkins console output when executing "php ./composer.phar install" Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 15 installs, 0 updates, 0 removals Syncing Organization/Organizationservices-php (1.3.39) into cache In Git.php line 471: Failed to execute git clone --mirror -- '[email protected]:Organization/OrganizationServ ices-PHP.git' '/root/.cache/composer/vcs/git-github.com-Organization-OrganizationServ ices-PHP.git/' Cloning into bare repository '/root/.cache/composer/vcs/git-github.com-Organization-OrganizationServices-PHP.git'... Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 14:56:09 14:56:09 14:56:09 update [--with WITH] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-dev] [--lock] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--no-autoloader] [--no-suggest] [--no-progress] [-w|--with-dependencies] [-W|--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [...] 14:56:09 14:56:09 The command '/bin/sh -c php ./composer.phar update' returned a non-zero code: 1

here is the updated stage of containerized jenkinsfile that's running on a docker container. sh ''' docker exec ${env.ID} /bin/bash -c "cd /root/app/ceReceipt && php ./composer.phar update"

docker exec ${env.ID} /bin/bash -c "cd /root/app/ceReceipt && php ./composer.phar install" """

Wondering why the job was working fine when running on jenkins agent but failing when running on docker container?

I have a credentialsId of username and password for github, is it possible to input the credentialsID in the json file to resolve the host key verification failed issue?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.