From efd7aa11dda3d529e90d7654c7cd58c0345f7803 Mon Sep 17 00:00:00 2001 From: Jonas Vento Date: Thu, 3 Mar 2022 14:51:35 +0100 Subject: [PATCH 1/3] Changed default of skip progress update --- .../github/status/GitHubSCMSourceStatusChecksTrait.java | 8 +++++++- .../resources/lib/github-checks/status/properties.jelly | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/checks/github/status/GitHubSCMSourceStatusChecksTrait.java b/src/main/java/io/jenkins/plugins/checks/github/status/GitHubSCMSourceStatusChecksTrait.java index a6f888fc..9e5909da 100644 --- a/src/main/java/io/jenkins/plugins/checks/github/status/GitHubSCMSourceStatusChecksTrait.java +++ b/src/main/java/io/jenkins/plugins/checks/github/status/GitHubSCMSourceStatusChecksTrait.java @@ -27,13 +27,14 @@ public class GitHubSCMSourceStatusChecksTrait extends SCMSourceTrait implements private boolean unstableBuildNeutral = false; private String name = "Jenkins"; private boolean suppressLogs = false; - private boolean skipProgressUpdates = false; + private boolean skipProgressUpdates = DescriptorImpl.defaultSkipProgressUpdates; /** * Constructor for stapler. */ @DataBoundConstructor public GitHubSCMSourceStatusChecksTrait() { + super(); } @@ -136,6 +137,11 @@ protected void decorateContext(final SCMSourceContext context) { */ @Extension public static class DescriptorImpl extends SCMSourceTraitDescriptor { + public static final boolean defaultSkipProgressUpdates; + + static { + defaultSkipProgressUpdates = true; + } /** * Returns the display name. * diff --git a/src/main/resources/lib/github-checks/status/properties.jelly b/src/main/resources/lib/github-checks/status/properties.jelly index 5edf45f1..230cccc4 100644 --- a/src/main/resources/lib/github-checks/status/properties.jelly +++ b/src/main/resources/lib/github-checks/status/properties.jelly @@ -9,6 +9,7 @@ + @@ -19,7 +20,7 @@ - + From 03724e52f7b563e97a7801cc81d7c275095f6864 Mon Sep 17 00:00:00 2001 From: Jonas Vento Date: Tue, 18 Oct 2022 15:29:59 +0200 Subject: [PATCH 2/3] intermediate commit for jan --- .../github/GitHubChecksGlobalConfig.java | 46 +++++++++++++++++++ .../GitHubSCMSourceStatusChecksTrait.java | 9 ++++ .../GitHubStatusChecksConfigurations.java | 9 ++++ .../status/GitHubStatusChecksProperties.java | 6 ++- .../status/GitSCMStatusChecksExtension.java | 5 ++ .../GitHubChecksGlobalConfig/config.jelly | 13 ++++++ .../lib/github-checks/status/properties.jelly | 14 +++--- 7 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 src/main/java/io/jenkins/plugins/checks/github/GitHubChecksGlobalConfig.java create mode 100644 src/main/resources/io/jenkins/plugins/checks/github/GitHubChecksGlobalConfig/config.jelly diff --git a/src/main/java/io/jenkins/plugins/checks/github/GitHubChecksGlobalConfig.java b/src/main/java/io/jenkins/plugins/checks/github/GitHubChecksGlobalConfig.java new file mode 100644 index 00000000..e735fa8a --- /dev/null +++ b/src/main/java/io/jenkins/plugins/checks/github/GitHubChecksGlobalConfig.java @@ -0,0 +1,46 @@ +package io.jenkins.plugins.checks.github; + +import hudson.Extension; +import jenkins.model.GlobalConfiguration; +import net.sf.json.JSONObject; +import org.kohsuke.stapler.StaplerRequest; + +@Extension +public class GitHubChecksGlobalConfig extends GlobalConfiguration { + + + private boolean skipProgressUpdates = false; + private boolean enforceSkipProgressUpdates = false; + + public static GitHubChecksGlobalConfig get() { + return GlobalConfiguration.all().get(GitHubChecksGlobalConfig.class); + } + + public GitHubChecksGlobalConfig() { + load(); + } + + public synchronized boolean isSkipProgressUpdates() { + return skipProgressUpdates; + } + + public synchronized void setSkipProgressUpdates(boolean skipProgressUpdates) { + this.skipProgressUpdates = skipProgressUpdates; + save(); + } + + public synchronized boolean isEnforceSkipProgressUpdates() { + return enforceSkipProgressUpdates; + } + + public synchronized void setEnforceSkipProgressUpdates(boolean enforceSkipProgressUpdates) { + this.enforceSkipProgressUpdates = enforceSkipProgressUpdates; + save(); + } + + @Override + public boolean configure(StaplerRequest req, JSONObject json) throws FormException { + req.bindJSON(this, json); + return true; + } +} diff --git a/src/main/java/io/jenkins/plugins/checks/github/status/GitHubSCMSourceStatusChecksTrait.java b/src/main/java/io/jenkins/plugins/checks/github/status/GitHubSCMSourceStatusChecksTrait.java index 9e5909da..6f8e69ba 100644 --- a/src/main/java/io/jenkins/plugins/checks/github/status/GitHubSCMSourceStatusChecksTrait.java +++ b/src/main/java/io/jenkins/plugins/checks/github/status/GitHubSCMSourceStatusChecksTrait.java @@ -1,5 +1,6 @@ package io.jenkins.plugins.checks.github.status; +import io.jenkins.plugins.checks.github.GitHubChecksGlobalConfig; import org.apache.commons.lang3.StringUtils; import org.kohsuke.stapler.DataBoundConstructor; @@ -29,6 +30,9 @@ public class GitHubSCMSourceStatusChecksTrait extends SCMSourceTrait implements private boolean suppressLogs = false; private boolean skipProgressUpdates = DescriptorImpl.defaultSkipProgressUpdates; + public GitHubChecksGlobalConfig globalConfig = GitHubChecksGlobalConfig.get(); + public boolean enforceSkipProgressUpdates = GitHubChecksGlobalConfig.get().isEnforceSkipProgressUpdates(); + /** * Constructor for stapler. */ @@ -73,6 +77,9 @@ public boolean isSkipNotifications() { return skipNotifications; } + @Override + public boolean isEnforceSkipProgressUpdates() { return enforceSkipProgressUpdates; } + @Override public boolean isSuppressLogs() { return suppressLogs; @@ -138,8 +145,10 @@ protected void decorateContext(final SCMSourceContext context) { @Extension public static class DescriptorImpl extends SCMSourceTraitDescriptor { public static final boolean defaultSkipProgressUpdates; + public static final boolean enforceSkipProgressUpdates; static { + enforceSkipProgressUpdates = GitHubChecksGlobalConfig.get().isEnforceSkipProgressUpdates(); defaultSkipProgressUpdates = true; } /** diff --git a/src/main/java/io/jenkins/plugins/checks/github/status/GitHubStatusChecksConfigurations.java b/src/main/java/io/jenkins/plugins/checks/github/status/GitHubStatusChecksConfigurations.java index f952d398..7f1d55a9 100644 --- a/src/main/java/io/jenkins/plugins/checks/github/status/GitHubStatusChecksConfigurations.java +++ b/src/main/java/io/jenkins/plugins/checks/github/status/GitHubStatusChecksConfigurations.java @@ -1,5 +1,7 @@ package io.jenkins.plugins.checks.github.status; +import hudson.model.Job; + /** * Configurations for users to customize status checks. */ @@ -39,6 +41,8 @@ public interface GitHubStatusChecksConfigurations { * @return true if progress updates should be skipped. */ boolean isSkipProgressUpdates(); + + boolean isEnforceSkipProgressUpdates(); } class DefaultGitHubStatusChecksConfigurations implements GitHubStatusChecksConfigurations { @@ -66,5 +70,10 @@ public boolean isSuppressLogs() { public boolean isSkipProgressUpdates() { return false; } + + @Override + public boolean isEnforceSkipProgressUpdates() { + return false; + } } diff --git a/src/main/java/io/jenkins/plugins/checks/github/status/GitHubStatusChecksProperties.java b/src/main/java/io/jenkins/plugins/checks/github/status/GitHubStatusChecksProperties.java index 4425fb98..c36ac7d1 100644 --- a/src/main/java/io/jenkins/plugins/checks/github/status/GitHubStatusChecksProperties.java +++ b/src/main/java/io/jenkins/plugins/checks/github/status/GitHubStatusChecksProperties.java @@ -5,6 +5,7 @@ import edu.hm.hafner.util.VisibleForTesting; +import io.jenkins.plugins.checks.github.GitHubChecksGlobalConfig; import org.jenkinsci.plugins.github_branch_source.GitHubSCMSource; import hudson.Extension; import hudson.model.Job; @@ -66,7 +67,10 @@ public boolean isSuppressLogs(final Job job) { @Override public boolean isSkipProgressUpdates(final Job job) { - return getConfigurations(job).orElse(DEFAULT_CONFIGURATION).isSkipProgressUpdates(); + if (GitHubChecksGlobalConfig.get().isEnforceSkipProgressUpdates()) + return GitHubChecksGlobalConfig.get().isSkipProgressUpdates(); + else + return getConfigurations(job).orElse(DEFAULT_CONFIGURATION).isSkipProgressUpdates(); } private Optional getConfigurations(final Job job) { diff --git a/src/main/java/io/jenkins/plugins/checks/github/status/GitSCMStatusChecksExtension.java b/src/main/java/io/jenkins/plugins/checks/github/status/GitSCMStatusChecksExtension.java index 8884dd39..a422c533 100644 --- a/src/main/java/io/jenkins/plugins/checks/github/status/GitSCMStatusChecksExtension.java +++ b/src/main/java/io/jenkins/plugins/checks/github/status/GitSCMStatusChecksExtension.java @@ -1,5 +1,6 @@ package io.jenkins.plugins.checks.github.status; +import io.jenkins.plugins.checks.github.GitHubChecksGlobalConfig; import org.apache.commons.lang3.StringUtils; import org.kohsuke.stapler.DataBoundConstructor; @@ -22,6 +23,7 @@ public class GitSCMStatusChecksExtension extends GitSCMExtension implements GitH private String name = "Jenkins"; private boolean suppressLogs; private boolean skipProgressUpdates = false; + public boolean enforceSkipProgressUpdates = GitHubChecksGlobalConfig.get().isEnforceSkipProgressUpdates(); /** * Constructor for stapler. @@ -56,6 +58,9 @@ public boolean isSkipProgressUpdates() { return skipProgressUpdates; } + @Override + public boolean isEnforceSkipProgressUpdates() { return enforceSkipProgressUpdates; } + @DataBoundSetter public void setSkipProgressUpdates(final boolean skipProgressUpdates) { this.skipProgressUpdates = skipProgressUpdates; diff --git a/src/main/resources/io/jenkins/plugins/checks/github/GitHubChecksGlobalConfig/config.jelly b/src/main/resources/io/jenkins/plugins/checks/github/GitHubChecksGlobalConfig/config.jelly new file mode 100644 index 00000000..8cc96bba --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/checks/github/GitHubChecksGlobalConfig/config.jelly @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/lib/github-checks/status/properties.jelly b/src/main/resources/lib/github-checks/status/properties.jelly index 230cccc4..cfba0547 100644 --- a/src/main/resources/lib/github-checks/status/properties.jelly +++ b/src/main/resources/lib/github-checks/status/properties.jelly @@ -17,10 +17,12 @@ - - - - - + //Was klappt: die Zeile unten innerhalb von Entry. Aber das wollen wir nicht, weil wir es überhaupt nicht anzeigen wollen, wenn es readOnly ist. + + + + + + From 282ee3d7f41cda202fa8c0066fe164cd751b9ea9 Mon Sep 17 00:00:00 2001 From: Jonas Vento Date: Tue, 18 Oct 2022 16:12:24 +0200 Subject: [PATCH 3/3] some clean up --- src/main/resources/lib/github-checks/status/properties.jelly | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/lib/github-checks/status/properties.jelly b/src/main/resources/lib/github-checks/status/properties.jelly index cfba0547..a864bf94 100644 --- a/src/main/resources/lib/github-checks/status/properties.jelly +++ b/src/main/resources/lib/github-checks/status/properties.jelly @@ -17,9 +17,8 @@ - //Was klappt: die Zeile unten innerhalb von Entry. Aber das wollen wir nicht, weil wir es überhaupt nicht anzeigen wollen, wenn es readOnly ist. - +