-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add caching feature in global config (refs #272)
- Loading branch information
1 parent
ef3289a
commit f5ca1d8
Showing
11 changed files
with
245 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
#!/bin/sh | ||
mvn versions:update-properties | ||
mvnDebug -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.204.1 -Denforcer.skip=true | ||
|
||
./mvnw versions:update-properties | ||
MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n" \ | ||
./mvnw hpi:run \ | ||
-Djava.util.logging.config.file=logging.properties \ | ||
-Djenkins.version=2.361.4 \ | ||
-Denforcer.skip=true \ | ||
-Dhudson.model.ParametersAction.keepUndefinedParameters=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
#!/bin/sh | ||
mvn versions:update-properties | ||
mvn hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.346.3 -Denforcer.skip=true | ||
./mvnw versions:update-properties | ||
./mvnw hpi:run \ | ||
-Djava.util.logging.config.file=logging.properties \ | ||
-Djenkins.version=2.361.4 \ | ||
-Denforcer.skip=true \ | ||
-Dhudson.model.ParametersAction.keepUndefinedParameters=true |
59 changes: 59 additions & 0 deletions
59
src/main/java/org/jenkinsci/plugins/gwt/global/CacheConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.jenkinsci.plugins.gwt.global; | ||
|
||
import hudson.Extension; | ||
import java.io.Serializable; | ||
import java.util.Optional; | ||
import jenkins.model.GlobalConfiguration; | ||
import net.sf.json.JSONObject; | ||
import org.kohsuke.stapler.DataBoundSetter; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
|
||
@Extension | ||
public class CacheConfig extends GlobalConfiguration implements Serializable { | ||
|
||
private static final long serialVersionUID = -3077539230674127483L; | ||
private static final int DEFAULT_GET_JOBS_CACHE_MINUTES = 15; | ||
|
||
public static CacheConfig get() { | ||
return GlobalConfiguration.all().get(CacheConfig.class); | ||
} | ||
|
||
private boolean cacheGetJobs; | ||
private int cacheGetJobsMinutes; | ||
|
||
public CacheConfig(final boolean cacheGetJobs, final Integer cacheGetJobsMinutes) { | ||
this.cacheGetJobs = cacheGetJobs; | ||
this.cacheGetJobsMinutes = cacheGetJobsMinutes; | ||
} | ||
|
||
public CacheConfig() { | ||
this.load(); | ||
} | ||
|
||
@Override | ||
public boolean configure(final StaplerRequest req, final JSONObject json) throws FormException { | ||
req.bindJSON(this, json); | ||
this.save(); | ||
return true; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setCacheGetJobs(final boolean cacheGetJobs) { | ||
this.cacheGetJobs = cacheGetJobs; | ||
} | ||
|
||
public boolean isCacheGetJobs() { | ||
return this.cacheGetJobs; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setCacheGetJobsMinutes(final int cacheGetJobsMinutes) { | ||
if (cacheGetJobsMinutes < 1) { | ||
this.cacheGetJobsMinutes = 1; | ||
} | ||
} | ||
|
||
public int getCacheGetJobsMinutes() { | ||
return Optional.ofNullable(this.cacheGetJobsMinutes).orElse(DEFAULT_GET_JOBS_CACHE_MINUTES); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 121 additions & 1 deletion
122
src/main/java/org/jenkinsci/plugins/gwt/jobfinder/JobFinderImpersonater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/resources/org/jenkinsci/plugins/gwt/global/CacheConfig/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" | ||
xmlns:d="jelly:define" | ||
xmlns:f="/lib/form" | ||
xmlns:l="/lib/layout" | ||
xmlns:st="jelly:stapler" | ||
xmlns:t="/lib/hudson" | ||
xmlns:c="/lib/credentials"> | ||
|
||
<f:section title="Generic Webhook Trigger Cache"> | ||
<f:entry title="Cache Get Jobs" field="cacheGetJobs"> | ||
<f:checkbox/> | ||
<f:description> | ||
If checked, the plugin will cache available configured jobs. So that the plugin does not need to retrieve that list when invoked. It will only cache when the <code>token</code>-parameter is supplied. | ||
</f:description> | ||
</f:entry> | ||
|
||
<f:entry title="Cache Get Jobs Minutes"> | ||
<f:textbox field="cacheGetJobsMinutes"/> | ||
<f:description> | ||
Time, in minutes, to keep the jobs in cache before they are refreshed. | ||
</f:description> | ||
</f:entry> | ||
</f:section> | ||
|
||
</j:jelly> |
5 changes: 5 additions & 0 deletions
5
src/main/resources/org/jenkinsci/plugins/gwt/global/CacheConfig/help-enabled.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div> | ||
<p> | ||
This feature is also documented <a href="https://github.com/jenkinsci/generic-webhook-trigger-plugin">here</a>. | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/org/jenkinsci/plugins/gwt/global/Whitelist/help-enabled.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<div> | ||
<p> | ||
See <a href="https://github.com/jenkinsci/generic-webhook-trigger-plugin">Generic Webhook Trigger Plugin</a> for details on how to configure and use this plugin. | ||
This feature is also documented <a href="https://github.com/jenkinsci/generic-webhook-trigger-plugin">here</a>. | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters