Skip to content

Commit

Permalink
Fix JENKINS-42482: Move properties from DataBoundConstructor to DataB…
Browse files Browse the repository at this point in the history
…oundSetter so that Job DSL treats them as optional

References jenkinsci/slack-plugin#236
  • Loading branch information
Daniel15 committed Mar 4, 2017
1 parent 378fabe commit 2c2dd13
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/dev/assets/work/jobs/test_jobdsl_seed/config.xml
@@ -0,0 +1,43 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<builders>
<javaposse.jobdsl.plugin.ExecuteDslScripts>
<scriptText>job(&apos;test-jobdsl-1&apos;) {
scm {
github &apos;Daniel15Test/JenkinsTest&apos;, &apos;master&apos;
}
triggers {
cron &apos;@midnight&apos;
}
steps {
shell &apos;&apos;&apos;
exit $(((${BUILD_NUMBER}/2)%2))
&apos;&apos;&apos;
}
publishers {
gitHubIssueNotifier {
}
}
}</scriptText>
<usingScriptText>true</usingScriptText>
<ignoreExisting>false</ignoreExisting>
<ignoreMissingFiles>false</ignoreMissingFiles>
<removedJobAction>IGNORE</removedJobAction>
<removedViewAction>IGNORE</removedViewAction>
<lookupStrategy>JENKINS_ROOT</lookupStrategy>
</javaposse.jobdsl.plugin.ExecuteDslScripts>
</builders>
<publishers/>
<buildWrappers/>
</project>
Expand Up @@ -25,6 +25,7 @@
import org.kohsuke.github.GHIssueState;
import org.kohsuke.github.GHRepository;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.StaplerRequest;

import javax.annotation.Nonnull;
Expand All @@ -43,6 +44,13 @@ public class GitHubIssueNotifier extends Notifier implements SimpleBuildStep {
private boolean issueReopen = false;
private boolean issueAppend = false;

/**
* Initialises the {@link GitHubIssueNotifier} instance.
*/
@DataBoundConstructor
public GitHubIssueNotifier() {
}

/**
* Initialises the {@link GitHubIssueNotifier} instance.
* @param issueTitle the issue title
Expand All @@ -52,7 +60,6 @@ public class GitHubIssueNotifier extends Notifier implements SimpleBuildStep {
* @param issueReopen reopen the issue
* @param issueAppend append to existing issue
*/
@DataBoundConstructor
public GitHubIssueNotifier(String issueTitle, String issueBody, String issueLabel, String issueRepo, boolean issueReopen, boolean issueAppend) {
this.issueTitle = issueTitle;
this.issueBody = issueBody;
Expand Down Expand Up @@ -203,6 +210,11 @@ public String getIssueTitle() {
return issueTitle;
}

@DataBoundSetter
public void setIssueTitle(String issueTitle) {
this.issueTitle = issueTitle;
}

/**
* Returns the issue body.
*
Expand All @@ -212,6 +224,11 @@ public String getIssueBody() {
return issueBody;
}

@DataBoundSetter
public void setIssueBody(String issueBody) {
this.issueBody = issueBody;
}

/**
* Returns the issue label.
*
Expand All @@ -221,6 +238,11 @@ public String getIssueLabel() {
return issueLabel;
}

@DataBoundSetter
public void setIssueLabel(String issueLabel) {
this.issueLabel = issueLabel;
}

/**
* Flag to switch between reopening an existing issue or
* creating a new one.
Expand All @@ -230,6 +252,11 @@ public boolean isIssueReopen() {
return issueReopen;
}

@DataBoundSetter
public void setIssueReopen(boolean issueReopen) {
this.issueReopen = issueReopen;
}

/**
* Flag to switch between commenting an issue on continuous failure or just on first failure.
* @return true if an issue should be commented continuously on feach failures.
Expand All @@ -238,6 +265,11 @@ public boolean isIssueAppend() {
return issueAppend;
}

@DataBoundSetter
public void setIssueAppend(boolean issueAppend) {
this.issueAppend = issueAppend;
}

/**
* An alternative repo to report the issues.
* @return the url of the issue repo if set
Expand All @@ -246,6 +278,11 @@ public String getIssueRepo() {
return issueRepo;
}

@DataBoundSetter
public void setIssueRepo(String issueRepo) {
this.issueRepo = issueRepo;
}

@Extension
public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> {
private String issueTitle = "$JOB_NAME $BUILD_DISPLAY_NAME failed";
Expand Down

0 comments on commit 2c2dd13

Please sign in to comment.