Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENTERPRISE-728: Use base revision if no previous successful commit is available. #6

Merged
merged 1 commit into from Dec 5, 2018

Conversation

jumarko
Copy link

@jumarko jumarko commented Dec 4, 2018

This was a problem when the build was first run for a new branch without any previous OK build.
In that case, the "GIT_PREVIOUS_SUCCESSFUL_COMMIT" env variable was set to null,
which lead to an exception in the Commit class constructor and early job termination.
See also: https://issues.jenkins-ci.org/browse/JENKINS-51324

The issue was introduced by recent refactoring (using Commit domain class instead of pure Strings).
However, even the former solution (with Strings) seems to be suboptimal,
because in that case following git command was used to get commit range:

git log --pretty='%%H' ..<current_commit_sha>"

, which lead to an empty commit range.

Stacktrace from the error report:

ERROR: Build step failed with exception
java.lang.IllegalArgumentException: A commit hash cannot be null - just don't do that
        at org.jenkinsci.plugins.codescene.Domain.Commit.<init>(Commit.java:15)
        at org.jenkinsci.plugins.codescene.CodeSceneBuilder.perform(CodeSceneBuilder.java:266)
        at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
        at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
        at hudson.model.Build$BuildExecution.build(Build.java:206)
        at hudson.model.Build$BuildExecution.doRun(Build.java:163)
        at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
        at hudson.model.Run.execute(Run.java:1798)
        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
        at hudson.model.ResourceController.execute(ResourceController.java:97)
        at hudson.model.Executor.run(Executor.java:429)

… available.

This was a problem when the build was first run for a new branch without any previous OK build.
In that case, the "GIT_PREVIOUS_SUCCESSFUL_COMMIT" env variable was set to null,
which lead to an exception in the Commit class constructor and early job termination.

The issue was introduced by recent refactoring (using Commit domain class instead of pure Strings).
However, even the former solution (with Strings) seems to be suboptimal,
because in that case following git command was used to get commit range:
```
git log --pretty='%%H' ..<current_commit_sha>"
```
, which lead to an empty commit range.
@jumarko
Copy link
Author

jumarko commented Dec 4, 2018

Copy link

@adamtornhill adamtornhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and a sensible fallback. I also did some regression testing and everything works as expected. +1

@jumarko jumarko merged commit fc40fa7 into master Dec 5, 2018
@jumarko jumarko deleted the juraj-728-null-commit-issue branch December 5, 2018 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants