[JIRA] (JENKINS-57260) git blame fails for out-of-tree builds

0 views
Skip to first unread message

jenkins@email.twam.info (JIRA)

unread,
Apr 30, 2019, 12:32:04 PM4/30/19
to jenkinsc...@googlegroups.com
Tobias Müller created an issue
 
Jenkins / Bug JENKINS-57260
git blame fails for out-of-tree builds
Issue Type: Bug Bug
Assignee: Ulli Hafner
Components: warnings-ng-plugin
Created: 2019-04-30 16:31
Priority: Minor Minor
Reporter: Tobias Müller

My pipeline checks out the source code in a separate folder by settings the option 

skipDefaultCheckout()

and then manually checking out the source into ${ws}/src in the first step via

stage('Prepare') {
  steps {
    dir('src') {
      checkout scm
    }
  }
}

Doxygen is then later build in ${ws}/build/doxygen using

stage('Doxygen') {
  steps {
    dir('build/doxygen') {
      bat '@ninja doxygen' // outputs log into doxygen/doxygen.log
    }
    recordIssues(aggregatingResults: true, enabledForFailure: true, tools: [ doxygen(name: 'Doxygen', pattern: 'build/doxygen/doxygen/doxygen.log') ] )
  }
}

Warnings the counted correctly but git blame fails with

[2019-04-27T12:26:27.192Z] [Doxygen] Successfully parsed file C:\workspace\workspace\doxygen0aa3610e\build\doxygen\doxygen\doxygen.log
[2019-04-27T12:26:27.192Z] [Doxygen] -> found 39 issues (skipped 0 duplicates)
[2019-04-27T12:26:27.573Z] [Doxygen] [-ERROR-] Can't determine head commit using 'git rev-parse'. Skipping blame.
[2019-04-27T12:26:27.573Z] [Doxygen] [-ERROR-] hudson.plugins.git.GitException: Command "git rev-parse "HEAD^{commit}"" returned status code 128:
[2019-04-27T12:26:27.573Z] stdout:
[2019-04-27T12:26:27.573Z] stderr: fatal: not a git repository (or any of the parent directories): .git

I also reported this in gitter on 27.4 and was asked to create this bug report here.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

ullrich.hafner@gmail.com (JIRA)

unread,
Jul 18, 2019, 10:37:01 AM7/18/19
to jenkinsc...@googlegroups.com
Ulli Hafner commented on Bug JENKINS-57260
 
Re: git blame fails for out-of-tree builds

You need to execute the warnings step within the dir('src') block. Otherwise the warnings plugin has no information about the storage of your source files.

mark.rzepka@lovion.de (JIRA)

unread,
Oct 18, 2019, 9:13:03 AM10/18/19
to jenkinsc...@googlegroups.com
m l commented on Bug JENKINS-57260

Using dir('src') does not really help

My pipeline checks out the source code in a separate folder by settings the option

skipDefaultCheckout()

I checkout the source into ${ws}/Platform via

        stage('Checkout') {
            steps {
                script {
                    def gitVarsPlatform = checkout([$class: 'GitSCM', 
                        branches: [[name: "${env.BRANCH_NAME}"]],
                        extensions: [[$class: 'CleanCheckout', $class: 'RelativeTargetDirectory', relativeTargetDir: 'Platform']], 
                        userRemoteConfigs: [[url: 'https://XXXXX.git', name: 'Platform', credentialsId: 'XXXX' ]]
                    ])
                    lastChanges since: 'LAST_SUCCESSFUL_BUILD', format:'SIDE',matching: 'LINE'
                }
            }
        }

When I start analyzing the warnings following way:

    post {
        always {
            dir('Platform') {
                recordIssues enabledForFailure: true, tool: msBuild()
            }
        }
     }

Warnings are counted correctly but git blame fails with

[Pipeline] dir
14:08:31  Running in C:\jenkins\w\latform_feature_jenkins_master_2\Platform
[Pipeline] {
[Pipeline] recordIssues
14:08:31  [MSBuild] Sleeping for 5 seconds due to JENKINS-32191...
14:08:36  [MSBuild] Parsing console log (workspace: 'C:\jenkins\w\latform_feature_jenkins_master_2\Platform')
14:08:45  using credential XXXX
14:08:45  using credential XXXX
14:08:50   > git rev-parse "HEAD^{commit}" # timeout=10
14:08:52  [MSBuild] [-ERROR-] Errors while extracting author and commit information from Git:
14:08:52  [MSBuild] [-ERROR-] - error running git blame on 'UnitTests/XXXXXXXXX/ServicePlugIn.UnitTest/TestCases/WhenSetXXXXXXXXXXXInvoked.cs' with revision 'AnyObjectId[be2c88e23e194da25873f9440a8f35d62ced0835]'
14:08:52  [MSBuild] [-ERROR-] org.eclipse.jgit.errors.MissingObjectException: Missing unknown be2c88e23e194da25873f9440a8f35d62ced0835
14:08:52  [MSBuild] [-ERROR-] 	at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:158)
14:08:52  [MSBuild] [-ERROR-] 	at org.eclipse.jgit.lib.ObjectReader.open(ObjectReader.java:227)
14:08:52  [MSBuild] [-ERROR-] 	at org.eclipse.jgit.blame.BlameGenerator.push(BlameGenerator.java:317)
14:08:52  [MSBuild] [-ERROR-] 	at org.eclipse.jgit.api.BlameCommand.call(BlameCommand.java:214)
14:08:52  [MSBuild] [-ERROR-]  [wrapped] org.eclipse.jgit.api.errors.JGitInternalException: Missing unknown be2c88e23e194da25873f9440a8f35d62ced0835
14:08:52  [MSBuild] [-ERROR-] 	at org.eclipse.jgit.api.BlameCommand.call(BlameCommand.java:232)
14:08:52  [MSBuild] [-ERROR-] 	at io.jenkins.plugins.git.forensics.blame.GitBlamer$BlameRunner.run(GitBlamer.java:265)

For comparison, when I start analyzing the warnings without dir statement:

    post {
        always {
            recordIssues enabledForFailure: true, tool: msBuild()
        }
     }

Warnings are counted correctly but git blame fails with

[Pipeline] recordIssues
13:15:40  [MSBuild] Sleeping for 5 seconds due to JENKINS-32191...
13:15:46  [MSBuild] Parsing console log (workspace: 'C:\jenkins\w\latform_feature_jenkins_master_2')
13:15:55  using credential XXXX
13:15:55  using credential XXXX
13:16:02   > git rev-parse "HEAD^{commit}" # timeout=10
13:18:05  [MSBuild] [-ERROR-] Errors while extracting author and commit information from Git:
13:18:05  [MSBuild] [-ERROR-] - no blame results for file <Platform/XXXXXXX/ProviderServicePlugIn/MetaInformation/AdditionalAddressFieldMetaInformation.cs>
13:18:05  [MSBuild] [-ERROR-] - no blame results for file <Platform//XXXXXXX/TypeHierarchicalPresenter.cs>
13:18:05  [MSBuild] [-ERROR-] - no blame results for file <Platform//XXXXXXX/Services/CoreService.cs>
13:18:05  [MSBuild] [-ERROR-] - no blame results for file ....
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

ullrich.hafner@gmail.com (JIRA)

unread,
Oct 18, 2019, 10:34:02 AM10/18/19
to jenkinsc...@googlegroups.com
Ulli Hafner started work on Bug JENKINS-57260
 
Change By: Ulli Hafner
Status: Open In Progress

ullrich.hafner@gmail.com (JIRA)

unread,
Oct 18, 2019, 10:38:03 AM10/18/19
to jenkinsc...@googlegroups.com

ullrich.hafner@gmail.com (JIRA)

unread,
Oct 23, 2019, 4:50:53 AM10/23/19
to jenkinsc...@googlegroups.com
Ulli Hafner resolved as Fixed
Change By: Ulli Hafner
Status: In Progress Resolved
Resolution: Fixed
Released As: 7.0.0

mark.rzepka@lovion.de (JIRA)

unread,
Jan 3, 2020, 10:34:03 AM1/3/20
to jenkinsc...@googlegroups.com
m l commented on Bug JENKINS-57260
 
Re: git blame fails for out-of-tree builds

After the fixes git blame does not fail when I start analyzing the warnings without dir statement (see comment of 2019-10-18). Thanx!

But this works for single git repository only    -  Git blame still fails for multiple git repositories.

 

An example with two git repositories:

My pipeline checks out the source code in separate folders by settings the option

skipDefaultCheckout()

I checkout the sources into ${ws}/Platform and ${ws}/Modules via

        stage('Checkout') {
            steps {
                script {
                    def gitVarsPlatform = checkout([$class: 'GitSCM', 
                        branches: [[name: "${env.BRANCH_NAME}"]],
                        extensions: [[$class: 'CleanCheckout', $class: 'RelativeTargetDirectory', relativeTargetDir: 'Platform']], 
                        userRemoteConfigs: [[url: 'https://XXXXX.git', name: 'Platform', credentialsId: 'XXXX' ]]
                    ])
                    lastChanges since: 'LAST_SUCCESSFUL_BUILD', format:'SIDE',matching: 'LINE'

                    def gitVarsModules = checkout([$class: 'GitSCM',
                        branches: [[name: "${env.BRANCH_NAME}"]],
                        extensions: [[$class: 'CleanBeforeCheckout'], [$class: 'RelativeTargetDirectory', relativeTargetDir: 'Modules']],
                        userRemoteConfigs: [[url: 'https://YYYYY_modules.git', name: 'Modules', credentialsId: 'YYYY']]
                    ])
                }
            }
        }

When I start analyzing the warnings without dir statement:

    post {
        always {
            recordIssues enabledForFailure: true, sourceCodeEncoding: 'UTF-8', tool: msBuild(reportEncoding: 'UTF-8')
        }
     }

Warnings are counted correctly but git blame fails with

[Pipeline] recordIssues
16:05:49  [MSBuild] Sleeping for 5 seconds due to JENKINS-32191...
16:05:54  [MSBuild] Parsing console log (workspace: 'C:\jenkins\w\_platform_feature_jenkins_master')
16:06:11  using credential XXXX
16:06:11  using credential XXXX
16:06:11  using credential XXXX
16:06:11   > git rev-parse "HEAD^{commit}" # timeout=10
16:06:11  using credential XXXX
16:06:11   > git rev-parse "HEAD^{commit}" # timeout=10
16:06:21   > git rev-parse "HEAD^{commit}" # timeout=10
16:10:39  [MSBuild] [-ERROR-] Errors while extracting author and commit information from Git:
16:10:39  [MSBuild] [-ERROR-] - skipping file 'C:/jenkins/w/_platform_feature_jenkins_master/Modules/XXXXXXX/AvailabilityCheckFeatures.cs' (outside of work tree)
16:10:39  [MSBuild] [-ERROR-] - skipping file 'C:/jenkins/w/_platform_feature_jenkins_master/Modules/XXXXXXX/SurveyProject.cs' (outside of work tree)
16:10:39  [MSBuild] [-ERROR-] - skipping file 'C:/jenkins/w/_platform_feature_jenkins_master/Modules/XXXXXXX/ExtensionRepositoriesHelper.cs' (outside of work tree)
16:10:39  [MSBuild] [-ERROR-] - skipping file ...

When I start analyzing the warnings with dir statements:

    post {
        always {
            dir('Platform') {
                recordIssues enabledForFailure: true, sourceCodeEncoding: 'UTF-8', tool: msBuild(reportEncoding: 'UTF-8')
            }
            dir('Modules') {
                recordIssues enabledForFailure: true, sourceCodeEncoding: 'UTF-8', tool: msBuild(reportEncoding: 'UTF-8')
            }
        }
   }

I get build Error:

[Pipeline] // dir
Error when executing always post condition:
java.lang.IllegalStateException: ID msbuild is already used by another action: io.jenkins.plugins.analysis.core.model.ResultAction for MSBuild

	at io.jenkins.plugins.analysis.core.steps.IssuesPublisher.ensureThatIdIsUnique(IssuesPublisher.java:139)
	at io.jenkins.plugins.analysis.core.steps.IssuesPublisher.attachAction(IssuesPublisher.java:106)
	at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.publishResult(IssuesRecorder.java:668)
	at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.record(IssuesRecorder.java:600)
	at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.perform(IssuesRecorder.java:565)
	at io.jenkins.plugins.analysis.core.steps.RecordIssuesStep$Execution.run(RecordIssuesStep.java:976)
	at io.jenkins.plugins.analysis.core.steps.RecordIssuesStep$Execution.run(RecordIssuesStep.java:939)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

mark.rzepka@lovion.de (JIRA)

unread,
Jan 3, 2020, 10:35:03 AM1/3/20
to jenkinsc...@googlegroups.com
m l reopened an issue
 

see last comment

Change By: m l
Resolution: Fixed
Status: Resolved Reopened

mark.rzepka@lovion.de (JIRA)

unread,
Jan 3, 2020, 10:35:04 AM1/3/20
to jenkinsc...@googlegroups.com
m l updated an issue
Change By: m l
Comment: see last comment

ullrich.hafner@gmail.com (JIRA)

unread,
Jan 3, 2020, 5:01:03 PM1/3/20
to jenkinsc...@googlegroups.com
Ulli Hafner commented on Bug JENKINS-57260
 
Re: git blame fails for out-of-tree builds

You need to use different IDs when using two recordIssues steps with the same tool.

mark.rzepka@lovion.de (JIRA)

unread,
Jan 6, 2020, 3:09:04 AM1/6/20
to jenkinsc...@googlegroups.com
m l commented on Bug JENKINS-57260

Unfortunately there are still errors when I start analyzing the warnings with dir statements including different IDs:

    post {
        always {
            dir('Platform') {
                recordIssues enabledForFailure: true, sourceCodeEncoding: 'UTF-8', tool: msBuild(id: 'Platform', reportEncoding: 'UTF-8')
            }
            dir('Modules') {
                recordIssues enabledForFailure: true, sourceCodeEncoding: 'UTF-8', tool: msBuild(id: 'Modules', reportEncoding: 'UTF-8')
            }
        }
   }

Git blame fails with:

[Pipeline] recordIssues
08:37:04  [MSBuild] Sleeping for 5 seconds due to JENKINS-32191...
08:37:09  [MSBuild] Parsing console log (workspace: 'C:\jenkins\w\_platform_feature_jenkins_master\Platform')
08:37:26  using credential buildpc-Git-User
08:37:27  using credential buildpc-Git-User
08:37:27  using credential buildpc-Git-User
08:37:26   > git rev-parse "HEAD^{commit}" # timeout=10
08:37:27  using credential buildpc-Git-User
08:37:27   > git rev-parse "HEAD^{commit}" # timeout=10
08:37:32   > git rev-parse "HEAD^{commit}" # timeout=10
08:37:34  [MSBuild] [-ERROR-] Errors while extracting author and commit information from Git:
08:37:34  [MSBuild] [-ERROR-] - skipping file 'C:/jenkins/w/_platform_feature_jenkins_master/Modules/XXXXXX/AvailabilityCheckFeatures.cs' (outside of work tree)
08:37:34  [MSBuild] [-ERROR-] - skipping file 'C:/jenkins/w/_platform_feature_jenkins_master/Platform/XXXXXX/EditableFlexibleAssociation.cs' (outside of work tree)
[...]
08:37:34  [MSBuild] [-ERROR-]   ... skipped logging of 270 additional errors ...
08:37:34  [MSBuild] [-ERROR-] Errors while mining source control repository:
08:37:34  [MSBuild] [-ERROR-] Can't analyze history of file C:/jenkins/w/_platform_feature_jenkins_master/Modules/XXXXXX/AvailabilityCheckFeatures.cs
08:37:34  [MSBuild] [-ERROR-] org.eclipse.jgit.api.errors.NoHeadException: No HEAD exists and no explicit starting revision was specified
08:37:34  [MSBuild] [-ERROR-] 	at org.eclipse.jgit.api.LogCommand.call(LogCommand.java:150)
08:37:34  [MSBuild] [-ERROR-] 	at io.jenkins.plugins.forensics.git.miner.GitRepositoryMiner$RepositoryStatisticsCallback.analyzeHistory(GitRepositoryMiner.java:121)
[...]
[Pipeline] // dir
[Pipeline] dir
08:37:34  Running in C:\jenkins\w\_platform_feature_jenkins_master\Modules
[Pipeline] {
[Pipeline] recordIssues
08:37:34  [MSBuild] Sleeping for 5 seconds due to JENKINS-32191...
08:37:39  [MSBuild] Parsing console log (workspace: 'C:\jenkins\w\_platform_feature_jenkins_master\Modules')
08:37:56  using credential buildpc-Git-User
08:37:56  using credential buildpc-Git-User
08:37:57  using credential buildpc-Git-User
08:37:56   > git rev-parse "HEAD^{commit}" # timeout=10
08:37:57  using credential buildpc-Git-User
08:37:57   > git rev-parse "HEAD^{commit}" # timeout=10
08:38:00   > git rev-parse "HEAD^{commit}" # timeout=10
08:38:02  [MSBuild] [-ERROR-] Errors while extracting author and commit information from Git:
08:38:02  [MSBuild] [-ERROR-] - skipping file 'C:/jenkins/w/_platform_feature_jenkins_master/Modules/XXXXXX/AvailabilityCheckFeatures.cs' (outside of work tree)
08:38:02  [MSBuild] [-ERROR-] - skipping file 'C:/jenkins/w/_platform_feature_jenkins_master/Platform/XXXXXX/EditableFlexibleAssociation.cs' (outside of work tree)
[...]
08:38:02  [MSBuild] [-ERROR-]   ... skipped logging of 270 additional errors ...
08:38:02  [MSBuild] [-ERROR-] Errors while mining source control repository:
08:38:02  [MSBuild] [-ERROR-] Can't analyze history of file C:/jenkins/w/_platform_feature_jenkins_master/Modules/XXXXXX/AvailabilityCheckFeatures.cs
08:38:02  [MSBuild] [-ERROR-] org.eclipse.jgit.api.errors.NoHeadException: No HEAD exists and no explicit starting revision was specified
08:38:02  [MSBuild] [-ERROR-] 	at org.eclipse.jgit.api.LogCommand.call(LogCommand.java:150)
08:38:02  [MSBuild] [-ERROR-] 	at io.jenkins.plugins.forensics.git.miner.GitRepositoryMiner$RepositoryStatisticsCallback.analyzeHistory(GitRepositoryMiner.java:121)

Additionally the solution with multiple (here two) dir statements is not what I want, since multiple (here two) static analysis warnings reports will be created. I want only one report for all the multiple git repositories.

ullrich.hafner@gmail.com (JIRA)

unread,
Feb 13, 2020, 4:32:04 PM2/13/20
to jenkinsc...@googlegroups.com
Ulli Hafner resolved as Fixed
 

There is also a source path option available now.

Change By: Ulli Hafner
Status: Reopened Resolved
Resolution: Fixed
Reply all
Reply to author
Forward
0 new messages