0

I have a Google Cloud Build trigger which builds my Spring Boot app. Now I have to use jar from private Github Maven repository. So I need to provide 'settings.xml' to build process to access this package. My cloud build config:

steps:
  - name: maven
    args:
      - clean
    id: Clean
    entrypoint: mvn
  - name: maven
    args:
      - install
      - '-Pdev'
    id: Install
    entrypoint: mvn
options:
  substitutionOption: ALLOW_LOOSE
  logging: CLOUD_LOGGING_ONLY

Example settings.xml file I should use to access my maven repository:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <activeProfiles>
        <activeProfile>github</activeProfile>
    </activeProfiles>
    <profiles>
        <profile>
            <id>github</id>
            <repositories>
                <repository>
                    <id>central</id>
                    <url>https://repo1.maven.org/maven2</url>
                </repository>
                <repository>
                    <id>github</id>
                    <url>https://maven.pkg.github.com/OWNER/REPO</url>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>
    <servers>
        <server>
            <id>github</id>
            <username>$_GITHUB_USERNAME</username>
            <password>$_GITHUB_TOKEN</password>
        </server>
    </servers>
</settings>

So I need to access to settings.xml and update with credentials. Is there any elegant way to do this?

Gismat Kazimli
  • 87
  • 1
  • 1
  • 8
  • Have you checked this [Github Link](https://github.com/GoogleCloudPlatform/cloud-builders/issues/44) – Sandeep Vokkareni Apr 12 '23 at 11:55
  • @SandeepVokkareni Thanks for the link. But this is about accessing repo. I need to access private maven repository in Github. – Gismat Kazimli Apr 12 '23 at 12:28
  • Have a look at this [Stackoverflow Link](https://stackoverflow.com/questions/73700067) which suggests to create additional steps in google cloud build to generate credentials and store them in the file (settings.xml), before running the maven step. Also check this [Github link](https://github.com/saturnism/spring-on-gcp-gitbook/blob/master/app-dev/devops/artifact-repository.md). – Sandeep Vokkareni Apr 14 '23 at 06:38

0 Answers0