Soh*_* بٹ 0 node.js npm jenkins reactjs yarnpkg
我正在尝试在 Jenkins 上配置我的项目,以便每次提交都会导致自动构建。当我yarn install使用 Jenkins NodeJS 脚本运行时,它拒绝安装从 git 存储库导入的依赖项。我正在按照以下方式进行操作。
"some-component": "git+https://bitbucket.org/owner/repo.git"
Run Code Online (Sandbox Code Playgroud)
它显示以下错误:
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.
Run Code Online (Sandbox Code Playgroud)
如果文件为空,则显示以下错误
error Couldn't find the binary git
error Command failed with exit code 1.
Run Code Online (Sandbox Code Playgroud)
尽管同样yarn install可以在 IDE(例如 VS Code)上完美运行。
yarn install我使用以下代码在 Jenkins 上的 NodeJS 脚本中执行
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);
}
});
Run Code Online (Sandbox Code Playgroud)
小智 5
我在 docker 容器中尝试从 git 存储库添加包时收到相同的错误。
$ 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.
Run Code Online (Sandbox Code Playgroud)
我认为yarn 尝试解析我使用的url 时出现问题;您可以使用不同的变体(例如 https、git+https、ssh)。来发现,我所在的docker容器没有安装git。因此,当 Yarn 的任务是尝试检索 git 存储库时,它没有 git 二进制文件来执行此操作。
解决方案:在docker容器中安装git
希望即使我的解决方案的上下文不同(我在 docker 容器中而不是在 Jenkins 工作中),如果您确保git在 Jenkins 工作中可以访问它,它可能会帮助解决您的问题。
您可以通过运行来测试这一点git --version,并且应该有一个版本输出证明您有或没有可用的 git。
| 归档时间: |
|
| 查看次数: |
5911 次 |
| 最近记录: |