GitLab CI:“权限被拒绝"拉私人作曲家包时 [英] GitLab CI: "Permission denied" when pulling private composer package

查看:60
本文介绍了GitLab CI:“权限被拒绝"拉私人作曲家包时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用GitLab设置CI,但出现此构建错误:

I'm trying to setup CI with GitLab but I'm getting this build error:

  [RuntimeException]         

  Failed to execute git clone --no-checkout 'git@***.git' '/builds/***' && cd '/builds/***' && git remote add composer 'git@***.git' && git fetch composer  
  Cloning into '/builds/***'...       

  Permission denied, please try again. 

  Permission denied, please try again.                                                                                 
  Permission denied (publickey,password).                                                                            
  fatal: Could not read from remote repository.                                                                        
  Please make sure you have the correct access rights                                                                       
  and the repository exists.   

我的composer.json看起来像这样:

My composer.json looks like this:

{
    "repositories": [
        {
            "type": "git",
            "url": "git@***.git"
        }],
}

它显然与ssh密钥对有关,但是我不知道在哪里存储私钥/公钥.

It obviously has something to do with the ssh key pair, but I don't know where to store the private/public keys.

推荐答案

我刚刚基于您基本上需要

  • 设置SSH代理(尤其是在使用docker时)
  • 添加私密SSH密钥(最好不存储在GitLab中的变量中,因为不应签入凭据)

例如,如果链接被移动:

Example, in case the link gets moved:

before_script:
  # install ssh-agent
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'

  # run ssh-agent
  - eval $(ssh-agent -s)

  # add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
  - ssh-add <(echo "$SSH_PRIVATE_KEY")

  # Set up project.
  - composer install 

这篇关于GitLab CI:“权限被拒绝"拉私人作曲家包时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆