Git-commit-id-maven-plugin: Git tag info is not getting populated while executing the plugin in google cloud build using maven:3.6.3-openjdk-11

Created on 29 Oct 2020  路  4Comments  路  Source: git-commit-id/git-commit-id-maven-plugin

the bug

Git tag info is not getting populated while executing the plugin in google cloud build using maven:3.6.3-openjdk-11.
I am trying to use the git properties generated by the plugin in maven build with <injectAllReactorProjects>true</injectAllReactorProjects> option.
The following info is getting populated -
git.branch
git.commit.id
git.commit.message
but the following are not getting populated only when it runs as a part of google cloud build
git.closest.tag.name
git.tags
but the above get populated when I run them locally.

Steps to Reproduce

 <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>4.0.2</version>
                <executions>
                    <execution>
                        <id>get-the-git-infos</id>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <useNativeGit>true</useNativeGit>
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
                    <injectAllReactorProjects>true</injectAllReactorProjects>
                    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
                    <gitDescribe>
                        <tags>true</tags>
                    </gitDescribe>
                </configuration>
            </plugin> 
  • Is there a (public) project where this issue can be reproduced? If so please provide a link.
    Unfortunately it's not a public project

  • Include any stack-traces or any error messages -
    i don't see any error message

Expected behavior

  • Please provide a description of what you expected to happen.
    I expect that the git tag info should be populated.

Additional context

For reproducibility please provide the following:

  • the plugin version is being used (if not included in the configuration) - 4.0.2
  • the Java-Version is being used (output of java -version and also include details about oracle-jdk VS open-jdk) - openjdk11
  • the Maven-Version is being used (output of mvn --version) - 3.6.3
  • on what Operating System you experience the bug (on Linux run lsb_release -a or cat /etc/*release*) - I think its linux; amd64
    linux; arm64 variant v8
  • in what context maven is being executed (e.g. inside Windows Terminal, Powershell, Git Bash, /bin/bash, ...)
    Inside google cloud build step - which looks likes this
- name: maven:3.6.3-openjdk-11
    entrypoint: mvn
    args: ["clean","package","-DgitTag=${TAG_NAME}","-DgoogleProjectId=${PROJECT_ID}","jib:build","--batch-mode","-DskipTests"]
    volumes:
      - path: '/cache/.m2'
        name: 'm2_cache'
    env:
      - MAVEN_OPTS=-Dmaven.repo.local=/cache/.m2
    id: 'mvn-jib-build'
- how maven is being executed (e.g. ``mvn clean deploy`` VS ``mvn deploy:deploy``)
mvn package
not-a-bug

Most helpful comment

Thanks a ton for replying to this - let me investigate that thoroughly and update here again.

All 4 comments

Hello,
thank you for creating an issue for this.
At first I somewhat suspected that this might be an issue with leightweight VS annotated tags, but that doesn't appear the issue in your case (since it's working on google cloud, but not locally).

Since you have the <useNativeGit>true</useNativeGit> setting enabled the plugin will be using the native git binary and to obtain the closest git-tag the plugin is running something along the lines of git describe HEAD --abbrev=0 --tags (see here. For the git tags-property the plugin would be running git tag --contains HEAD (see here).

Now do you get the same output when you run this locally VS on the cloud system? Do you use some mechanism that happens to create the tags in the cloned repo on the clound server, but perhaps doesn't publish them to the actual repo? Or in other words are the tags visible to the cloud build visible inside the git repo (e.g. via git show-ref --tags or git tag -l)? Do you perhaps have a shallow clone locally (e.g. git clone -鈥揹epth [depth] [remote-url] or git clone [remote-url] --branch [name] --single-branch [folder]?

Maybe that gives an already good indicator what might be going on.

Thanks a ton for replying to this - let me investigate that thoroughly and update here again.

Just curious: Have you discovered the root cause of this issue?

Since I haven't heard back, I'm going ahead and close this issue. if this is still an issue, please feel free to reopen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VK2BEA picture VK2BEA  路  5Comments

darrenbkl picture darrenbkl  路  3Comments

DanielKuehner picture DanielKuehner  路  8Comments

Santonian picture Santonian  路  4Comments

delanym picture delanym  路  7Comments