Skip to content

Commit

Permalink
refs #10 Added failed flag to CopiedjobinfoAction, indicates an error…
Browse files Browse the repository at this point in the history
… occurred when copying additional files.
  • Loading branch information
ikedam committed Feb 23, 2013
1 parent 874f9a3 commit 6618e37
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public String getFromJobName()
return this.fromJobName;
}

public String fromUrl;
private String fromUrl;

/**
* Returns the URI (path) of the job copied from.
Expand All @@ -66,7 +66,7 @@ public String getFromUrl()
return this.fromUrl;
}

public String toJobName;
private String toJobName;

/**
* Returns the name of the job copied to.
Expand All @@ -78,7 +78,7 @@ public String getToJobName()
return this.toJobName;
}

public String toUrl;
private String toUrl;

/**
* Returns the URI (path) of the job copied to.
Expand All @@ -93,19 +93,33 @@ public String getToUrl()
return this.toUrl;
}

private boolean failed;

/**
* Returns whether the job is copied incompletely
*
* @return whether the job is copied incompletely
*/
public boolean isFailed()
{
return failed;
}

/**
*
* constructor.
*
* @param fromItem job that was copied from.
* @param toItem job that was copied to.
* @param failed whether the job is copied incompletely.
*/
public CopiedjobinfoAction(TopLevelItem fromItem, TopLevelItem toItem)
public CopiedjobinfoAction(TopLevelItem fromItem, TopLevelItem toItem, boolean failed)
{
this.fromJobName = fromItem.getName();
this.fromUrl = fromItem.getUrl();
this.toJobName = toItem.getName();
this.toUrl = toItem.getUrl();
this.failed = failed;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,20 @@ else if(!(fromJob instanceof Job<?,?>))
target.updateByXml(new StreamSource(is));
}

boolean failed = false;

if(getAdditionalFilesetList() != null && !getAdditionalFilesetList().isEmpty())
{
listener.getLogger().println("Copying Additional Files...");
for(AdditionalFileset fileset: getAdditionalFilesetList())
{
// TODO: copy and apply operations to the file.
// TODO: set failed if failed.
}
}

// add the information of jobs copied from and to to the build.
build.addAction(new CopiedjobinfoAction(fromJob, toJob));
build.addAction(new CopiedjobinfoAction(fromJob, toJob, failed));

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,11 @@ THE SOFTWARE.
<a href="${baseURL}/${it.toUrl}">${it.toJobName}</a>
</f:entry>
</l:pane>
<j:if test="${it.failed}">
<div class="warning">
The job is copied, but an error occurred in the process.
Check the build log and the configuration of the copied job, for something wrong may be in them.
</div>
</j:if>
</t:summary>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testView() throws IOException, InterruptedException, ExecutionExcept

// Create job, and create a build.
FreeStyleProject job = createFreeStyleProject();
CopiedjobinfoAction action = new CopiedjobinfoAction(fromJob, toJob);
CopiedjobinfoAction action = new CopiedjobinfoAction(fromJob, toJob, false);
FreeStyleBuild build = job.scheduleBuild2(job.getQuietPeriod(), new Cause.UserIdCause(), action).get();

// Wait for build is completed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public void testCopiedjobinfoAction()
TopLevelItem toItem = new DummyJob(toItemName, toItemUrl);
CopiedjobinfoAction target = new CopiedjobinfoAction(
fromItem,
toItem
toItem,
false
);

assertEquals(fromItemName, target.getFromJobName());
Expand Down

0 comments on commit 6618e37

Please sign in to comment.