Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Google Cloud Build时如何将私有存储库凭据传递给maven docker image_Maven_Docker_Google Cloud Platform_Google Cloud Build_Docker Maven Plugin - Fatal编程技术网

使用Google Cloud Build时如何将私有存储库凭据传递给maven docker image

使用Google Cloud Build时如何将私有存储库凭据传递给maven docker image,maven,docker,google-cloud-platform,google-cloud-build,docker-maven-plugin,Maven,Docker,Google Cloud Platform,Google Cloud Build,Docker Maven Plugin,我正在尝试使用GoogleCloudBuild来构建我的Java应用程序。它允许使用所谓的云构建器——不同构建器的docker图像。我正在使用Maven。所以问题是我必须使用私有存储库(artifactory)来部署工件。此代表受密码保护,我不知道如何将这些凭据传递给GC maven docker容器 我认为唯一可行的办法是: 要运行shell脚本,该脚本将使用以下内容更新maven container settings.xml: <servers> <server&g

我正在尝试使用GoogleCloudBuild来构建我的Java应用程序。它允许使用所谓的云构建器——不同构建器的docker图像。我正在使用Maven。所以问题是我必须使用私有存储库(artifactory)来部署工件。此代表受密码保护,我不知道如何将这些凭据传递给GC maven docker容器

我认为唯一可行的办法是:

  • 要运行shell脚本,该脚本将使用以下内容更新maven container settings.xml:

    <servers>
        <server>
            <id>myRepoName</id>
            <username>${server.username}</username>
            <password>${server.password}</password>
        </server>
    </servers>
    
    
    我的名字
    ${server.username}
    ${server.password}
    
  • 在cloudbuild.yml中设置环境变量


  • 有没有其他优雅的方法可以达到我想要达到的目标?

    我通过以下方法解决了这个问题:

  • 创建一个谷歌云存储桶并上传您想要的
    设置.xml
    。我正在使用GitHub包,如下所示

  • 使用以下内容设置cloudbuild.yaml:

  • 首先,它将settings.xml复制到当前目录(
    /workspace
    )。然后,直接使用Docker Maven图像,将
    --settings/workspace/settings.xml
    添加到参数中,以指定settings.xml位置。从那时起,Google Cloud Build就能够提取我的私有GitHub包来正确安装我的项目

    在第一步中,可以复制到
    /usr/share/maven/ref/
    ,以允许默认的maven Docker行为,但我无法实现这一点。如果有人知道,请告诉我


    根据和

    据我所知,您的存储库需要使用SSH密钥进行访问控制。下面是GitHub私有存储库的一个示例@约翰汉利:我认为OP是在问Maven存储库,而不是github中的git存储库。@Karthikeyanvaitillingam-OP是在问云构建。“我的链接”是访问私有存储库的一个示例。@JohnHanley您的链接提供了访问github私有存储库的示例,但OP需要访问私有存储库。您还可以查看。
    steps:
      - name: gcr.io/cloud-builders/gsutil
        args: ['cp', 'gs://ci-maven/settings.xml', 'settings.xml']
      - name: maven:3.6.3-jdk-11-openj9
        entrypoint: 'mvn'
        args: ['--settings', '/workspace/settings.xml', 'install']
    images: ['gcr.io/schemata-np/scheduler']