diff --git a/plugin/src/main/java/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder.java b/plugin/src/main/java/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder.java index 1ca49187..151068f2 100644 --- a/plugin/src/main/java/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder.java +++ b/plugin/src/main/java/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder.java @@ -12,7 +12,6 @@ import org.jenkinsci.Symbol; import hudson.Extension; import hudson.model.Run; -import jenkins.scm.api.SCMHead; import io.jenkins.plugins.forensics.reference.ReferenceRecorder; import io.jenkins.plugins.util.JenkinsFacade; @@ -78,8 +77,7 @@ public boolean isSkipUnknownCommits() { @Override protected Optional> find(final Run owner, final Run lastCompletedBuildOfReferenceJob, final FilteredLog log) { - Optional referenceCommit - = GitCommitsRecord.findRecordForScm(lastCompletedBuildOfReferenceJob, getScm()); + var referenceCommit = GitCommitsRecord.findRecordForScm(lastCompletedBuildOfReferenceJob, getScm()); Optional> referenceBuild; if (referenceCommit.isPresent()) { @@ -95,7 +93,7 @@ public boolean isSkipUnknownCommits() { return referenceBuild; } - Optional targetBranchHead = findTargetBranchHead(owner.getParent()); + var targetBranchHead = findTargetBranchHead(owner.getParent()); if (targetBranchHead.isPresent()) { log.logInfo("-> falling back to latest build '%s' since a pull or merge request has been detected", lastCompletedBuildOfReferenceJob.getDisplayName()); @@ -108,13 +106,12 @@ public boolean isSkipUnknownCommits() { private Optional> findByCommits(final Run owner, final GitCommitsRecord referenceCommit, final FilteredLog log) { - Optional ownerCommits = GitCommitsRecord.findRecordForScm(owner, getScm()); + var ownerCommits = GitCommitsRecord.findRecordForScm(owner, getScm()); if (ownerCommits.isPresent()) { - GitCommitsRecord commitsRecord = ownerCommits.get(); - Optional> referencePoint = commitsRecord.getReferencePoint( - referenceCommit, getMaxCommits(), isSkipUnknownCommits(), log); + var commitsRecord = ownerCommits.get(); + var referencePoint = commitsRecord.getReferencePoint(referenceCommit, getMaxCommits(), isSkipUnknownCommits(), log); if (referencePoint.isPresent()) { - Run referenceBuild = referencePoint.get(); + var referenceBuild = referencePoint.get(); log.logInfo("-> found build '%s' in reference job with matching commits", referenceBuild.getDisplayName()); diff --git a/plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/config.jelly b/plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/config.jelly index 586badde..2dd48f04 100644 --- a/plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/config.jelly +++ b/plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/config.jelly @@ -17,11 +17,16 @@ - - + + - - + + + + + + + diff --git a/plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/config.properties b/plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/config.properties index 81e9216c..5221e918 100644 --- a/plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/config.properties +++ b/plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/config.properties @@ -6,3 +6,4 @@ description.maxCommits=Defines how many commits of a job''s Git history should b title.targetBranch=Target Branch title.skipUnknownCommits=Ignore reference job builds with commits that are not part of the current build title.latestBuildIfNotFound=Fallback to the latest-completed build if no reference build has been found +title.considerRunningBuild=Consider running builds as reference diff --git a/plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/help-considerRunningBuild.html b/plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/help-considerRunningBuild.html new file mode 100644 index 00000000..880a0452 --- /dev/null +++ b/plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/help-considerRunningBuild.html @@ -0,0 +1,3 @@ +If enabled, then running builds will be considered as reference build as well. Otherwise, only completed builds +are considered. Enabling this option might cause problems if the reference build has not yet all the +required results available.