如何使用DEPLOY_TOKEN从Gitlab私有仓库安装R包?

问题描述 投票:0回答:1

首先,来个工作命令。

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

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

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

install 工作!但可以访问 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。

使用DEPLOY_TOKEN,在.Renviron文件中设置,只对包含包的repo有读取权限。

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包吗?

r gitlab-ci
1个回答
0
投票

我找到了关于群组部署token的有用视频。https:/www.youtube.comembed8kxTJvaD9ks?rel=0

给出了int。

git clone https://gitlab+deploy-token-157011:[email protected]/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-157011andDEPLOY_TOKEN=-vz-oxsbL2y_ffdZoedq。

© www.soinside.com 2019 - 2024. All rights reserved.