I am trying to configure my project on Jenkins so that each commit will result in an automatic build. When I run yarn install
using Jenkins NodeJS script, it resist to install the the dependencies that are being imported from git repository. I am doing it the following way.
"some-component": "git+https://bitbucket.org/owner/repo.git"
It shows following error:
error Command failed.
Exit code: 128
Command: git
Arguments: clone git+https://bitbucket.org/owner/repo.git
Output:
fatal: destination path 'some path' already exists and is not an empty directory.
error Command failed with exit code 1.
If the file is empty it show following error
error Couldn't find the binary git
error Command failed with exit code 1.
Although the same yarn install
works perfectly on IDE eg VS Code.
I am using the following code to execute yarn install
in NodeJS Script on Jenkins
var exec = require('child_process').exec,
child;
child = exec('yarn install ',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
I was receiving the same error while trying to add a package from a git repository while in a docker container.
$ yarn add git+https://git@github.com/username/some_repo.git
error Couldn't find the binary git
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
I thought there was an issue with yarn trying to parse the url I used; there are different variations you can use (like https, git+https, ssh). Come to find out, the docker container I was in, did not have git installed . So when yarn was tasked with trying to retrieve the git repository, it didn't have the git binary to do so.
Solution: Install git in the docker container
Hopefully even though the context of my solution is different (I was in a docker container and not in Jenkins job), it might help solve your problem if you ensure that git
is accessible in your Jenkins job.
You can test this by running git --version
and there should be a version output proving that you do or don't have git available.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.