简体   繁体   English

IBM Cloud Code Engine 无法为私有存储库构建

[英]IBM Cloud Code Engine fails to build for private repo

I'm using IBM Cloud Code Engine to build the source code from a private git repo .我正在使用IBM Cloud Code Engine 从私有 git 存储库构建源代码 I have tried many times, and the buildrun always failed.我试过很多次,buildrun总是失败。 Following are the steps I have done.以下是我已经完成的步骤。

  1. Add my public key (/root/.ssh/id_rsa.pub) to my private repo as a deploy key将我的公钥 (/root/.ssh/id_rsa.pub) 作为部署密钥添加到我的私人仓库

  2. Use IBM Cloud Code Engine CLI to create repo access credential ibmcloud ce repo create --name ibmgithub --key-path /root/.ssh/id_rsa --host github.ibm.com使用 IBM Cloud Code Engine CLI 创建存储库访问凭证ibmcloud ce repo create --name ibmgithub --key-path /root/.ssh/id_rsa --host github.ibm.com

  3. Use IBM Cloud Code Engine CLI to create a build and then submit a build run ibmcloud ce build create --name minion --image us.icr.io/mynamespace/myimg --rs ce-default-icr-us-south --git-repo-secret ibmgithub --source https://github.ibm.com/myaccount/myrepo --strategy dockerfile --size medium使用 IBM Cloud Code Engine CLI 创建构建,然后提交构建运行ibmcloud ce build create --name minion --image us.icr.io/mynamespace/myimg --rs ce-default-icr-us-south --git-repo-secret ibmgithub --source https://github.ibm.com/myaccount/myrepo --strategy dockerfile --size medium

  4. The build run always fails构建运行总是失败

#:~/synthetics-private-minion# ibmcloud ce bd get -n minion
Getting build 'minion'
OK
Name:          minion  
ID:            0abc63a0-07d5-42c5-b70a-227e52310276  
Project Name:  private location  
Project ID:    25491342-e9e8-4ac7-90ff-b9994cda9242  
Age:           6m24s  
Created:       2021-03-31T04:11:41-05:00  
Status:        Succeeded  
Reason:        all validations succeeded  
Image:            us.icr.io/mynamespace/myimg 
Registry Secret:  ce-default-icr-us-south  
Build Strategy:   kaniko-medium  
Timeout:          10m0s  
Source:           https://github.ibm.com/myaccount/myrepo  
Commit:           main  
Dockerfile:       Dockerfile  
Repo Secret:      ibmgithub  
Build Runs:    
  Name              Status                                                                                                                                                                                                                                                                                                                            Age  
  minion-run-sj5fl  "step-git-source-source-cm7pc" exited with code 1 (image: "icr.io/obs/codeengine/tekton-pipeline/git-init-4874978a9786b6625dd8b6ef2a21aa70@sha256:47b8008fa1910fa36c8284871eb9d8e7fbab8bc3a1db4cdd97c61d88727cc58f"); for logs run: kubectl -n 7pztl5cw3ad logs minion-run-sj5fl-nbzft-pod-rx9x9 -c step-git-source-source-cm7pc  5m42s  
  1. I doubt the build run failed to fetch the source code from my private repo.我怀疑构建运行无法从我的私人仓库中获取源代码。 And I checked on the repo UI, it shows the deploy key Never used .我检查了 repo UI,它显示了部署密钥Never used

Can anyone shed some light on it?任何人都可以对此有所了解吗? Thanks.谢谢。

The build capability of IBM Cloud Code Engine can access source code in public and private repositories. IBM Cloud Code Engine 的构建功能可以访问公共和私有存储库中的源代码。 There are two criteria for a repository to be public:公开存储库有两个标准:

  1. The repository must be marked as public at your repository provider (for example GitHub, or GitLab).该存储库必须在您的存储库提供商处标记为公共(例如 GitHub 或 GitLab)。
  2. The repository must be accessible without any authentication.存储库必须无需任何身份验证即可访问。 This plays a role for GitHub Enterprise installations, for example github.ibm.com, which can put an additional authentication in front to prevent anonymous access.这对 GitHub Enterprise 安装起作用,例如 github.ibm.com 可以在前面放置额外的身份验证以防止匿名访问。

The second criteria makes your repository a private one from Code Engine perspective.从代码引擎的角度来看,第二个标准使您的存储库成为私有存储库。 To address a repository in a Code Engine build, there is a simple rule:要在代码引擎构建中处理存储库,有一个简单的规则:

  • For a public repository, use the HTTPS URL of the repository and no repository access secret对于公共存储库,使用存储库的 HTTPS URL 并且没有存储库访问密钥
  • For a private repository, use the SSH URL of the repository and a repository access secret对于私有存储库,使用存储库的 SSH URL 和存储库访问密钥

You correctly specify a repository access secret, but must change your source URL to use the SSH protocol.您正确指定了存储库访问密钥,但必须更改您的源 URL 以使用 SSH 协议。 The easiest way to find the URL, is the Code drop-down in GitHub:找到 URL 的最简单方法是 GitHub 中的代码下拉菜单:

GitHub 代码下拉菜单

So it should be git@github.ibm.com/myaccount/myrepo in your case.所以在你的情况下应该是git@github.ibm.com/myaccount/myrepo

Further references:更多参考资料:

Instructions on how to setup a repository access secret can be found in Accessing private code repositories .可以在访问私有代码存储库中找到有关如何设置存储库访问密钥的说明。

Troubleshooting for a failed BuildRun can be found in Troubleshooting tips for builds .构建运行失败的故障排除可以在构建故障排除提示中找到。 It includes instructions to retrieve the logs from your BuildRun and translates the error message you see into the root cause with steps to resolve them.它包括从 BuildRun 检索日志的说明,并将您看到的错误消息转换为根本原因以及解决它们的步骤。

Since you're using an ssh key, make sure the URL to your git repo starts with git@ instead of https:// . Since you're using an ssh key, make sure the URL to your git repo starts with git@ instead of https:// . So it should be git@github.ibm.com/myaccount/myrepo in your case.所以在你的情况下应该是git@github.ibm.com/myaccount/myrepo

For further issues with failing builds, you can check the related troubleshooting buildruns section in the Code Engine docs .有关构建失败的更多问题,您可以查看代码引擎文档中的相关故障排除构建运行部分

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IBM Cloud Code Engine:构建在步骤“step-build-and-push”中失败,错误为 UNAUTHORIZED - IBM Cloud Code Engine: Build fails in step “step-build-and-push” with error UNAUTHORIZED 使用端口 80 部署标准容器时,IBM Cloud Code Engine 修订失败 - IBM Cloud Code Engine revision fails when deploying standard container with port 80 IBM Cloud Code Engine:当应用程序不活动时如何检查日志? - IBM Cloud Code Engine: How to check logs when app not active? IBM Cloud:如何将 Db2 Warehouse 绑定到 Code Engine 应用程序? - IBM Cloud: How to bind Db2 Warehouse to Code Engine app? IBM Cloud Code Engine:如何从环境中确定应用程序 URL? - IBM Cloud Code Engine: How to determine app URL from environment? IBM Cloud Code Engine:有状态应用程序和粘性会话、扩展问题 - IBM Cloud Code Engine: Stateful Apps and Sticky Sessions, Scaling Issues IBM Cloud:尝试创建 Code Engine 项目时出错 - IBM Cloud: Error trying to create Code Engine project 来自GitHub的IBM Bluemix演示,node.js cloudant示例,“部署到IBM云”按钮失败,无法找到存储库 - IBM Bluemix demo from GitHub, node.js cloudant sample, “Deploy to IBM cloud” button fails with unable to find repo IBM云:无法构建应用 - IBM cloud : Cannot build app IBM Cloud Code Engine:如何在没有 CLI 的情况下从 GitLab 源部署应用程序 - IBM Cloud Code Engine: How can I deploy an app from GitLab source without CLI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM