【问题标题】:Starting a VM on GCP in Jenkin Pipeline using gcloud使用 gcloud 在 Jenkins Pipeline 中的 GCP 上启动 VM
【发布时间】:2021-06-14 14:11:39
【问题描述】:

我的目标是创建一个用于测试的自动化系统,我想在另一个 GCP 项目中创建一个 VM 以在其上安装独立的 Packager,并从 Jenkins 工作人员对其运行测试。

  1. 我在 GCP 上创建了一个 VM,首先我对附加到项目的服务帐户进行身份验证,我通过将凭据文件上传到 git repo 来使用它,这在安全性方面是不安全的,然后从 Jenkins 工作区访问 .json (Credentials) 文件.有没有更好的办法。

  2. 通过 SSH 连接。如何使用 SSH 连接此 VM,我已附加一个日志映像。我正在 Jenkins 上运行两个项目,另一个在 GCP 上运行。

Image is Log when I tried to build Jenkins Pipeline

【问题讨论】:

    标签: python-3.x google-cloud-platform jenkins-pipeline


    【解决方案1】:

    我假设 Jenkins 不在 GCP 上运行。对于您的第一个主题,您可以使用plugin in Jenkins 上传文件,我敢肯定,jenkins 会保守秘密!

    第二个问题可以使用gcloud cli to open a ssh connection

    【讨论】:

    • 我尝试使用 gcloud 打开连接,但是当管道构建时,它会给出错误 ssh ,-> 无法通过 SSH 连接到实例。您的 SSH 密钥可能尚未传播到实例。
    • 是的,这是可能的。您还可以在元数据中手动设置 SSH 密钥,并在打开 ssh 连接时使用相关的私钥。这一次,您直接使用 ssh,而不是 gcloud 命令。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多