Skip to content

Commit

Permalink
Add MaxCC parameter [JENKINS-29214].
Browse files Browse the repository at this point in the history
  • Loading branch information
candiduslynx committed Jul 17, 2015
1 parent c97fa5c commit 712a2ec
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
Expand Up @@ -55,6 +55,11 @@ public class zOSJobSubmitter extends Builder {
*/
private String job;

/**
* MaxCC to decide that job ended OK.
*/
private String MaxCC;

/**
* Constructor. Invoked when 'Apply' or 'Save' button is pressed on the project configuration page.
*
Expand All @@ -68,7 +73,16 @@ public class zOSJobSubmitter extends Builder {
* @param job JCL of the job to be submitted.
*/
@DataBoundConstructor
public zOSJobSubmitter (String server, int port, String userID, String password, boolean wait, int waitTime, boolean deleteJobFromSpool, String job)
public zOSJobSubmitter (
String server,
int port,
String userID,
String password,
boolean wait,
int waitTime,
boolean deleteJobFromSpool,
String job,
String MaxCC)
{
// Copy values
this.server = server.replaceAll("\\s","");
Expand All @@ -79,6 +93,14 @@ public zOSJobSubmitter (String server, int port, String userID, String password,
this.waitTime = waitTime;
this.deleteJobFromSpool = deleteJobFromSpool;
this.job = job;
if (MaxCC == null || MaxCC.isEmpty()) {
this.MaxCC = "0000";
} else {
this.MaxCC = MaxCC;
if (this.MaxCC.length() < 4) {
this.MaxCC = "000".substring(0,4-this.MaxCC.length()) + this.MaxCC;
}
}
}

/**
Expand Down Expand Up @@ -114,9 +136,11 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis
if(printableCC != null)
printableCC = printableCC.replaceAll("\\s+","");

// Print the info about the job
listener.getLogger().println("Job [" + zFTPConnector.getJobID() + "] processing finished.");

// If wait was requested try to save the job log.
if(this.wait)
{
if(this.wait) {
// Save the log.
try
{
Expand All @@ -139,14 +163,12 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis
{
i.printStackTrace();
}
}
else
{
} else {
printableCC = "0000"; //set RC = 0
}

// Return whether the job succeeded or not.
return result && "0000".equals(printableCC);
return result && (this.MaxCC.compareTo(printableCC) >= 0);
}

/**
Expand Down Expand Up @@ -219,13 +241,20 @@ public int getWaitTime()
/**
* Get Job.
*
* @return <b><code>job</code></b>
* @return <b><code>Job</code></b>
*/
public String getJob()
{
return this.job;
}

/**
* @return <b><code>MaxCC of the job to be considered OK</code></b>
*/
public String getMaxCC() {
return this.MaxCC;
}

/**
* Get descriptor for this class.
*
Expand Down Expand Up @@ -333,14 +362,21 @@ public FormValidation doCheckInput(@QueryParameter String value)
* @throws ServletException
*/
public FormValidation doCheckWaitTime(@QueryParameter String value)
throws IOException, ServletException {
throws IOException, ServletException {
if (!value.matches("\\d*"))
return FormValidation.error("Value must be numeric");
if(Integer.parseInt(value) < 0)
return FormValidation.error("Value must not be negative");
return FormValidation.ok();
}

public FormValidation doCheckMaxCC(@QueryParameter String value)
throws IOException, ServletException {
if (!value.matches("(\\d{1,4})|(\\s*)"))
return FormValidation.error("Value must be 4 decimal digits or empty");
return FormValidation.ok();

}
/**
* If this build step can be used with the project.
*
Expand Down
Expand Up @@ -24,6 +24,9 @@
<f:entry field="deleteJobFromSpool" title="Delete job log from Spool?">
<f:checkbox default="false" value="${it.getDeleteJobFromSpool()}"/>
</f:entry>
<f:entry field="MaxCC" title="MaxCC" description='Default or empty = "0000"'>
<f:textbox value="${it.getMaxCC()}" default=""/>
</f:entry>
</f:optionalBlock>
</table>
</f:block>
Expand Down

0 comments on commit 712a2ec

Please sign in to comment.