-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add global config for hook url override (#164)
* Add global config vor hook url override * Remove load() Co-authored-by: Christian Del Monte <[email protected]>
- Loading branch information
Christian Del Monte
and
Christian Del Monte
authored
Feb 10, 2021
1 parent
45a064e
commit 10f0757
Showing
7 changed files
with
129 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "recommended", | ||
"groovyLint.format.enable": true, | ||
"rules": { | ||
"formatting.Indentation": { | ||
"spacesPerIndentLevel": 2, | ||
"severity": "info" | ||
}, | ||
"UnnecessaryReturnKeyword": "error" | ||
} | ||
} |
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
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
60 changes: 60 additions & 0 deletions
60
.../java/io/jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRPluginConfig.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,60 @@ | ||
package io.jenkins.plugins.bitbucketpushandpullrequest.config; | ||
|
||
import static org.apache.commons.lang3.StringUtils.isEmpty; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.util.logging.Logger; | ||
import org.kohsuke.stapler.DataBoundSetter; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
import hudson.Extension; | ||
import hudson.ExtensionList; | ||
import jenkins.model.GlobalConfiguration; | ||
import net.sf.json.JSONObject; | ||
|
||
@Extension | ||
public class BitBucketPPRPluginConfig extends GlobalConfiguration { | ||
private static final Logger logger = Logger.getLogger(BitBucketPPRPluginConfig.class.getName()); | ||
public static final String BITBUCKET_PPR_PLUGIN_CONFIGURATION_ID = "bitbucket-ppr-plugin-configuration"; | ||
|
||
@SuppressWarnings("unused") | ||
public String hookUrl; | ||
|
||
public BitBucketPPRPluginConfig() { | ||
logger.fine("Read bitbucket push and pull request plugin global configuration."); | ||
load(); | ||
} | ||
|
||
public static BitBucketPPRPluginConfig getInstance() { | ||
return ExtensionList.lookupSingleton(BitBucketPPRPluginConfig.class); | ||
} | ||
|
||
@DataBoundSetter | ||
public void setHookUrl(String hookUrl) { | ||
if (isEmpty(hookUrl)) { | ||
this.hookUrl = ""; | ||
} else { | ||
this.hookUrl = hookUrl; | ||
} | ||
save(); | ||
} | ||
|
||
public boolean isHookUrlSet() { | ||
return ! isEmpty(hookUrl); | ||
} | ||
|
||
public String getHookUrl() { | ||
return hookUrl; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Bitbucket Push and Pull Request"; | ||
} | ||
|
||
@Override | ||
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { | ||
req.bindJSON(this, formData); | ||
save(); | ||
return true; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
.../jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRPluginConfig/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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" | ||
xmlns:t="/lib/hudson" xmlns:f="/lib/form"> | ||
<f:section title="${%BitBucket Push and Pull Request}"> | ||
<f:entry title="Hook URL" field="hookUrlTitle"> | ||
<f:textbox field="hookUrl" /> | ||
</f:entry> | ||
</f:section> | ||
</j:jelly> |