Skip to content

Make some settings optional in pipelines #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,27 @@
public class StashBuildTrigger extends Trigger<Job<?, ?>> {
private static final Logger logger =
Logger.getLogger(MethodHandles.lookup().lookupClass().getName());

// Required settings
private final String cron;
private final String stashHost;
private final String credentialsId;
private final String projectCode;
private final String repositoryName;
private final String ciSkipPhrases;
private final String ciBuildPhrases;
private final String targetBranchesToBuild;
private final boolean ignoreSsl;
private final boolean checkDestinationCommit;
private final boolean checkMergeable;
private final boolean mergeOnSuccess;
private final boolean checkNotConflicted;
private final boolean onlyBuildOnComment;
private final boolean deletePreviousBuildFinishComments;
private final boolean cancelOutdatedJobsEnabled;

private boolean checkProbeMergeStatus;

// Optional settings
private boolean ignoreSsl;
private String targetBranchesToBuild = "";
private boolean checkDestinationCommit;
private boolean checkNotConflicted;
private boolean checkMergeable;
private boolean checkProbeMergeStatus = true;
private boolean mergeOnSuccess;
private boolean deletePreviousBuildFinishComments;
private boolean cancelOutdatedJobsEnabled;
private String ciSkipPhrases = DescriptorImpl.DEFAULT_CI_SKIP_PHRASES;
private boolean onlyBuildOnComment;
private String ciBuildPhrases = DescriptorImpl.DEFAULT_CI_BUILD_PHRASES;

private transient StashPullRequestsBuilder stashPullRequestsBuilder;

Expand All @@ -63,52 +66,24 @@ public StashBuildTrigger(
String stashHost,
String credentialsId,
String projectCode,
String repositoryName,
String ciSkipPhrases,
boolean ignoreSsl,
boolean checkDestinationCommit,
boolean checkMergeable,
boolean mergeOnSuccess,
boolean checkNotConflicted,
boolean onlyBuildOnComment,
String ciBuildPhrases,
boolean deletePreviousBuildFinishComments,
String targetBranchesToBuild,
boolean cancelOutdatedJobsEnabled)
String repositoryName)
throws ANTLRException {
super(cron);
this.cron = cron;
this.stashHost = stashHost;
this.credentialsId = credentialsId;
this.projectCode = projectCode;
this.repositoryName = repositoryName;
this.ciSkipPhrases = ciSkipPhrases;
this.cancelOutdatedJobsEnabled = cancelOutdatedJobsEnabled;
this.ciBuildPhrases = ciBuildPhrases == null ? "test this please" : ciBuildPhrases;
this.ignoreSsl = ignoreSsl;
this.checkDestinationCommit = checkDestinationCommit;
this.checkMergeable = checkMergeable;
this.mergeOnSuccess = mergeOnSuccess;
this.checkNotConflicted = checkNotConflicted;
this.onlyBuildOnComment = onlyBuildOnComment;
this.deletePreviousBuildFinishComments = deletePreviousBuildFinishComments;
this.targetBranchesToBuild = targetBranchesToBuild;
}

@DataBoundSetter
public void setCheckProbeMergeStatus(boolean checkProbeMergeStatus) {
this.checkProbeMergeStatus = checkProbeMergeStatus;
public String getCron() {
return this.cron;
}

public String getStashHost() {
return stashHost;
}

public String getCron() {
return this.cron;
}

// Needed for Jelly Config
public String getCredentialsId() {
return this.credentialsId;
}
Expand Down Expand Up @@ -142,38 +117,114 @@ public String getRepositoryName() {
return repositoryName;
}

public String getCiSkipPhrases() {
return ciSkipPhrases;
public boolean getIgnoreSsl() {
return ignoreSsl;
}

public String getCiBuildPhrases() {
return ciBuildPhrases == null ? "test this please" : ciBuildPhrases;
@DataBoundSetter
public void setIgnoreSsl(boolean ignoreSsl) {
this.ignoreSsl = ignoreSsl;
}

public String getTargetBranchesToBuild() {
return targetBranchesToBuild;
}

@DataBoundSetter
public void setTargetBranchesToBuild(String targetBranchesToBuild) {
this.targetBranchesToBuild = targetBranchesToBuild;
}

public boolean getCheckDestinationCommit() {
return checkDestinationCommit;
}

public boolean getIgnoreSsl() {
return ignoreSsl;
@DataBoundSetter
public void setCheckDestinationCommit(boolean checkDestinationCommit) {
this.checkDestinationCommit = checkDestinationCommit;
}

public boolean getDeletePreviousBuildFinishComments() {
return deletePreviousBuildFinishComments;
public boolean getCheckNotConflicted() {
return checkNotConflicted;
}

public String getTargetBranchesToBuild() {
return targetBranchesToBuild;
@DataBoundSetter
public void setCheckNotConflicted(boolean checkNotConflicted) {
this.checkNotConflicted = checkNotConflicted;
}

public boolean getCheckMergeable() {
return checkMergeable;
}

@DataBoundSetter
public void setCheckMergeable(boolean checkMergeable) {
this.checkMergeable = checkMergeable;
}

public boolean getCheckProbeMergeStatus() {
return checkProbeMergeStatus;
}

@DataBoundSetter
public void setCheckProbeMergeStatus(boolean checkProbeMergeStatus) {
this.checkProbeMergeStatus = checkProbeMergeStatus;
}

public boolean getMergeOnSuccess() {
return mergeOnSuccess;
}

@DataBoundSetter
public void setMergeOnSuccess(boolean mergeOnSuccess) {
this.mergeOnSuccess = mergeOnSuccess;
}

public boolean getDeletePreviousBuildFinishComments() {
return deletePreviousBuildFinishComments;
}

@DataBoundSetter
public void setDeletePreviousBuildFinishComments(boolean deletePreviousBuildFinishComments) {
this.deletePreviousBuildFinishComments = deletePreviousBuildFinishComments;
}

public boolean getCancelOutdatedJobsEnabled() {
return cancelOutdatedJobsEnabled;
}

@DataBoundSetter
public void setCancelOutdatedJobsEnabled(boolean cancelOutdatedJobsEnabled) {
this.cancelOutdatedJobsEnabled = cancelOutdatedJobsEnabled;
}

public String getCiSkipPhrases() {
return ciSkipPhrases;
}

@DataBoundSetter
public void setCiSkipPhrases(String ciSkipPhrases) {
this.ciSkipPhrases = ciSkipPhrases;
}

public boolean getOnlyBuildOnComment() {
return onlyBuildOnComment;
}

@DataBoundSetter
public void setOnlyBuildOnComment(boolean onlyBuildOnComment) {
this.onlyBuildOnComment = onlyBuildOnComment;
}

public String getCiBuildPhrases() {
return ciBuildPhrases;
}

@DataBoundSetter
public void setCiBuildPhrases(String ciBuildPhrases) {
this.ciBuildPhrases = ciBuildPhrases;
}

@Override
public void start(Job<?, ?> job, boolean newInstance) {
super.start(job, newInstance);
Expand Down Expand Up @@ -212,23 +263,10 @@ public void stop() {
super.stop();
}

public boolean getCheckMergeable() {
return checkMergeable;
}

public boolean getCheckNotConflicted() {
return checkNotConflicted;
}

public boolean getCheckProbeMergeStatus() {
return checkProbeMergeStatus;
}

public boolean getOnlyBuildOnComment() {
return onlyBuildOnComment;
}

public static final class DescriptorImpl extends TriggerDescriptor {
public static final String DEFAULT_CI_SKIP_PHRASES = "NO TEST";
public static final String DEFAULT_CI_BUILD_PHRASES = "test this please";

public DescriptorImpl() {
load();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
<f:checkbox default="false"/>
</f:entry>
<f:entry title="Phrase to disable builds" field="ciSkipPhrases">
<f:textbox default="NO TEST" />
<f:textbox default="${descriptor.DEFAULT_CI_SKIP_PHRASES}"/>
</f:entry>
<f:entry title="Only build if asked with the build phrase" field="onlyBuildOnComment">
<f:checkbox default="false"/>
</f:entry>
<f:entry title="Phrase to request a (re-)build" field="ciBuildPhrases">
<f:textbox default="test this please"/>
<f:textbox default="${descriptor.DEFAULT_CI_BUILD_PHRASES}"/>
</f:entry>
</f:advanced>
</j:jelly>