r - 如何使用 DEPLOY_TOKEN 从 Gitlab 私有存储库安装 R 包?
问题描述
首先,一个工作命令:
使用 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 仅对包含包的 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 包吗?
解决方案
我在组部署令牌上找到了有用的视频https://www.youtube.com/embed/8kxTJvaD9ks?rel=0
这给了int:
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
推荐阅读
- python-3.x - 矢量化标记法文文本
- python - 逐行读取文本文件并计算一行中具有特定值的特定单词
- css - Bootstrap v3 hidden-* 特定断点宽度处的错误
- jquery - 我想每次都更新结果,但不明白我该怎么做
- kubernetes - 如何将所有证书从一台服务器上的 Kubernetes 复制到另一台服务器上的 Kubernetes?
- c - 为什么指针只增加一次
- c++ - 使用 set 方法从未排序的数组中删除重复项
- data-structures - 如何处理 ECS 中的动态分层实体
- android - Unity 2018 或 2019 减小 APK 或 .ipa 文件的大小
- image-upload - 前端图片上传并在typo3中构建文件引用