如何使用DEPLOY_TOKEN从Gitlab私有存储库安装R软件包?

时间:2020-04-21 21:27:30

标签: r gitlab-ci

首先,一个有效的命令:

使用GITLAB_PAT变量,在.Renviron文件中设置

cred <- git2r::cred_token( token = 'GITLAB_PAT' );

remotes::install_gitlab('myuser/myproject',
                        credentials = cred ,upgrade = FALSE )

安装有效!但可以访问myuser的所有私有软件包。

使用envvar GITLAB_PAT中的GitLab PAT

Downloading GitLab repo myuser/myproject@master

from URL https://gitlab.com/api/v4/projects/12345678/repository/archive.tar.gz?sha=master

√  checking for file 'C:\Users\myuser\AppData\Local\Temp\RtmpCMKBuc\remotes7e0820dc515b\myproject-master-b31c5baa8f1d2d4967b00b739216cbb9b50d74b1/DESCRIPTION' (2.8s)
-  preparing 'myproject': (526ms)
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'myproject_0.1.0.tar.gz'
...

** testing if installed package keeps a record of temporary installation path

* DONE (myproject)

第二,我无法使用的尝试使用DEPLOY_TOKEN:

使用.Renviron文件中设置的DEPLOY_TOKEN,仅对包含该程序包的存储库具有读取权限

cred <- git2r::cred_token( token = 'MYPROJECT_TOKEN' );

remotes::install_gitlab('myuser/myproject',
                        credentials = cred ,upgrade = FALSE )

->消息说使用Gitlab PAT授予访问权限,这不是我想要的。

使用envvar GITLAB_PAT中的GitLab PAT

Skipping install of 'myproject' from a gitlab remote, the SHA1 (b31c5bac) has not changed since last install.

Use `force = TRUE` to force installation

总而言之,我可以使用DEPLOY_TOKEN从Gitlab上的私有项目安装R软件包吗?

1 个答案:

答案 0 :(得分:0)

我发现有关组部署令牌https://www.youtube.com/embed/8kxTJvaD9ks?rel=0的有用视频

给出整数的

git clone https://gitlab+deploy-token-157011:-vz-oxsbL2y_ffdZoedq@gitlab.com/myuser/myproject.git

在这个方向上,这可行: (摘自.gitlab-ci.yml)

`- R -e "devtools::install_git(paste0('https://',Sys.getenv('DEPLOY_USERNAME'),":", 
                         Sys.getenv('DEPLOY_TOKEN'),
                         '@gitlab.com/myuser/myproject.git"'), upgrade = FALSE)"`

带有gitlab变量

DEPLOY_USERNAME = gitlab + deploy-token-157011 和 DEPLOY_TOKEN = -vz-oxsbL2y_ffdZoedq

相关问题