配置
CF CLI 版本
cf 版本
比照版本6.37.0+a40009753.2018-05-25
构建包版本https://github.com/cloudfoundry/nodejs-buildpack
listapplications:
- 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 上使用私有(private)存储库,因此 cf (cloudfoundry) 构建代理失败 npm install
因为它尝试登录/密码连接(被拒绝),而它应该使用 Git token ...
使用 Travis CI 自动构建。
预期行为
Cloudfoundry(或 Travis?)代理在运行 npm install
时应使用 git token
实际行为
它坚持使用登录名/密码凭据,因此 github 抛出 you should use git token or ssh key instead
据我所知,问题是我们正在使用私有(private)存储库,声明如下:git+https://github.com/someone/awesome-private-pkg.git
(我们不能使用 npm publish 等...)
当 cloudfoundry 尝试使用登录/密码凭据 npm 安装私有(private)存储库时将抛出错误
这是我的错误日志:
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 docs
这张表在访问方面非常明确,因为我正在深入研究使用 SSH 获取所有私有(private)模块 Deploy Key
方法 ( git+ssh://git@github.ibm.com/org/app
),使用单个 SSH key 获取所有 repo 协议(protocol)变得相当困难......
因此他们建议 User Key
这是最好的方法,但我无法应用,因为 GitHub Enterprise 将 1 个公司邮件地址绑定(bind)到 1 个 GHubE 帐户(SAML 东西)
就像我在帖子中所说的那样,我无法以正确的方式提供正确的信用我没有弄清楚 .netrc
文件根据 Password
存在和 API token
方法
显然它将 travis 代理设置为使用所需的登录类型(ssh 除外)!
非常感谢@DanielMikusa 的帮助!
关于git - 如何使用 Git token 通过 Travis CI/Cloudfoundry 访问私有(private)存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51051749/