git - 如何使用 Git 令牌通过 Travis CI / Cloudfoundry 访问私有存储库?
问题描述
配置
CF CLI 版本
cf version
cf 版本 6.37.0+a40009753.2018-05-25
构建包版本https://github.com/cloudfoundry/nodejs-buildpack
显现applications:
- path: .
memory: 2048M
instances: 1
buildpack: nodejs_buildpack
name: kpb-singlenode-api-tmp
command: node server.js
disk_quota: 2048M
部署.sh
#!/bin/bash
./Bluemix_CLI/bin/ibmcloud config --check-version false
./Bluemix_CLI/bin/ibmcloud api $API_ENDPOINT
./Bluemix_CLI/bin/ibmcloud login --apikey $API_KEY
./Bluemix_CLI/bin/ibmcloud target -o $IBMCLOUD_ORGANIZATION -s $IBMCLOUD_SPACE
./Bluemix_CLI/bin/ibmcloud app push kpb-node-api
.travis.yml
language: node_js
node_js:
- '8'
script: echo "skipping tests"
before_deploy:
- curl -L https://clis.ng.bluemix.net/download/bluemix-cli/latest/linux64 | tar -zx
- chmod -R u+x ./Bluemix_CLI/bin
- chmod +x ./deploy.sh
deploy:
provider: script
script: ./deploy.sh
on:
repo: myrepo/kpb-node-api
branch: master
skip_cleanup: true
问题
我只是想在 IBM Cloud (cloudfoundry) 上推送我的应用程序,但我在 github Enterprise 上使用私有存储库,因此 cf (cloudfoundry) 构建代理失败npm install
,因为它尝试登录/密码连接(被拒绝),而它应该使用 Git令牌...
使用 Travis CI 自动构建。
预期行为
Cloudfoundry(或 Travis?)代理应在运行时使用 git 令牌npm install
实际行为
它坚持登录/密码凭据,所以 github 抛出you should use git token or ssh key instead
据我所知,问题是我们正在使用一个私有存储库,声明如下:(git+https://github.com/someone/awesome-private-pkg.git
我们不能使用 npm publish 等......)当 cloudfoundry 尝试使用 login/ 安装私有存储库时将引发错误密码凭据
这是我的错误日志:
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t https://github.ibm.com/myrepo/kpb-api-pkg
npm ERR!
npm ERR! remote: Password authentication is not available for Git operations.
npm ERR! remote: You must use a personal access token or SSH key.
npm ERR! remote: See https://github.ibm.com/settings/tokens or https://github.ibm.com/settings/ssh
npm ERR! fatal: unable to access 'https://github.ibm.com/myrepo/kpb-api-pkg/': The requested URL returned error: 403
npm ERR!
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR! /home/travis/.npm/_logs/2018-06-26T10_31_07_934Z-debug.log
我正在挖掘.bashrc
可能通过以下方式设置变量git config --global git.token
感谢您的帮助,祝您有美好的一天!
解决方案
所以你只需要添加以下内容:
before_install:
- echo -e "machine github.ibm.com\n login $GIT_TOKEN" > ~/.netrc
到你的.travis.yml
解决方案本身就来自Travis 文档
该表在访问方面非常明确,因为我正在深入研究使用 SSHDeploy Key
方法(git+ssh://git@github.ibm.com/org/app
因此他们建议了User Key
最好的方法,但我不能申请,因为GitHub Enterprise将 1 个公司邮件地址绑定到 1 个 GHubE 帐户(SAML 内容)
就像我在帖子中所说的那样,我无法以正确的方式提供正确的凭据,我没有弄清楚.netrc
文件根据Password
和API token
方法存在
显然,它将 travis 代理设置为使用所需的登录类型(ssh 除外)!
非常感谢@DanielMikusa 的帮助!
推荐阅读
- python - 如何在 Python 中显示该过程:InsertionSort
- typescript - 打字稿:创建具有相同键但不同值的对象
- r - 在 R 控制台输出中右对齐字符串字符列
- java - 如何在 Java 中创建阻塞线程安全流?
- php - MySQL:如何只选择每个不同的 x-column-name 中的三个
- java - 无法读取文档 URL:无法读取整个标题;读取 6 个字节;预期 32 字节
- animation - SVG - animateMotion 不适用于 Firefox 中的 USE 元素
- python - MySQL:使用“SELECT INTO OUTFILE”时对字符串进行wiered chopping
- java - 数据源在 WebLogic 12.2 上无故丢失
- telegram - 如何确保chat_id 存在?