Re: Want something like "failonerror", for artifactspublisher

Doug Breaux <[email protected]>
Newsgroups gmane.comp.java.cruise-control.user
Message-ID <[email protected]>
Hmmm... so Publish failure will never cause Build failure, eh? So much for 
that approach. Was hoping for a "catch-all" at Publish time, but I guess 
that's not going to happen.

I'll have to try to find a way to cause build failure, as you say. And, yes, 
build is with Ant.

Thanks for the investigation.

On 8/13/2010 10:38 AM, Dan Rollo wrote:
> Hi Doug,
>
> I may be missing the point here, but looking at the source code of the
> Project.publish() method, no publisher failure should cause the build to
> be treated as "failed". By the time the "publish" phase begins, by
> definition, the "build" phase has completed (and has either failed or not).
>
> http://cruisecontrol.svn.sourceforge.net/viewvc/cruisecontrol/trunk/cruisecontrol/main/src/net/sourceforge/cruisecontrol/Project.java?revision=4521&view=markup
>
>
>       /**
>        * Iterate over all of the registered<code>Publisher</code>s and call
>        * their respective<code>publish</code>  methods.
>        * @param buildLog the content to publish
>        * @throws CruiseControlException if an error occurs during publishing
>        */
>       protected void publish(final Log buildLog) throws
> CruiseControlException {
>           setState(ProjectState.PUBLISHING);
>           for (final Publisher publisher : projectConfig.getPublishers()) {
>               // catch all errors, Publishers shouldn't cause failures in
> the build method
>               try {
>                   publisher.publish(buildLog.getContent());
>               } catch (Throwable t) {
>                   final StringBuilder message = new
> StringBuilder("exception publishing results");
>                   message.append(" with
> ").append(publisher.getClass().getName());
>                   message.append(" for project ").append(name);
>                   LOG.error(message.toString(), t);
>               }
>           }
>       }
>
> One thought - if you know why the publish is failing (eg: a generated
> file is missing), have you tried adding a check for that file to the
> "build" phase for the project?
> If using an Ant builder, you could do this with a small change to the
> build.xml to check for the required file to publish.
> Another approach is to use a Composite builder, where the last builder's
> job is to check for the needed file.
>
> The idea is to detect the error condition during the "build" phase,
> where you can still affect the "pass/fail" status of the overall build.
>
> Dan
>
>
> Date: Wed, 11 Aug 2010 17:56:17 -0500
> Subject: Re: [Cruisecontrol-user] Want something like "failonerror"
> 	for	artifactspublisher
> To: [email protected]
>
> Bah, my Ant copy still didn't fail when the file being copied didn't exist.
>
> 	<copy todir="${publishDest}/${projectname}/${cctimestamp}">
> 		<fileset dir="${publishSource}">
> 			<include name="${publishInclude}"/>
> 		</fileset>
> 	</copy>
>
>
> On 7/26/2010 2:02 PM, Marc W. wrote:
>   >  >  I found myself replacing my antpublisher tasks with an Ant script
> called by
>   >  >  antpublisher.  I simply used the passed property, cctimestamp, to
> locate the
>   >  >  proper artifact directory within Ant.
>   >  >
>   >  >  I'm currently working on getting Ant's output logged (or copied) to the
>   >  >  appropriate build's artifacts directory though.
>   >  >
>   >  >  HTH,
>   >  >  -Marc
>   >  >
>   >  >
>   >  >  On Mon, Jul 26, 2010 at 11:50, Doug Breaux
> <[email protected]
>   >  >  <mailto:[email protected]>>  wrote:
>   >  >
>   >  >      So any advice/ideas here? I still need to see a CC build
> failure if the
>   >  >      artifactspublisher can't find its file(s) to copy.
>   >  >
>   >  >      On 5/26/2010 8:33 AM, [email protected]
>   >  >      <mailto:[email protected]>  wrote:
>   >  >       >  I just finished dealing with a similar problem with the CVS
>   >  >      bootstrapper. The
>   >  >       >  CVS update generated some warnings, which caused the process
> to return a 1
>   >  >       >  instead of 0. This prevented the subsequent ant build from
> running. Since
>   >  >       >  there is no notification tied to the CVS failure, this
> problem went
>   >  >      unnoticed
>   >  >       >  for over a week.
>   >  >       >
>   >  >       >  Joel
>   >  >       >
>   >  >       >  -----Original Message-----
>   >  >       >  From: "Assaf Lavie"<[email protected]
> <mailto:[email protected]>>
>   >  >       >  Sent: Wednesday, May 26, 2010 2:44am
>   >  >       >  To: [email protected]
>   >  >      <mailto:[email protected]>
>   >  >       >  Subject: Re: [Cruisecontrol-user] Want something like
> "failonerror" for
>   >  >       >  artifactspublisher
>   >  >       >
>   >  >       >  What sort of build task isn't failing on error? I'm aware of
> such a problem
>   >  >       >  with Ant, for example, but it's fixable.
>   >  >       >
>   >  >       >  On Mon, May 24, 2010 at 8:38 PM, Doug Breaux
>   >  >      <[email protected]<mailto:[email protected]>
>   >  >       >  <mailto:[email protected]
>   >  >      <mailto:[email protected]>>>  wrote:
>   >  >       >
>   >  >       >      Is there any way to get CC to consider the build failed
> if the
>   >  >       >      artifactspublisher fails? It's logging an error about
> not being
>   >  >      able to copy
>   >  >       >      the file in question, but CC still says the build was
> successful.
>   >  >       >
>   >  >       >      (I have some build-type tasks that are not causing the
> build to
>   >  >      fail when they
>   >  >       >      fail, despite failOnError="true", and it seems one of
> the simplest
>   >  >      ways to
>   >  >       >      catch all of them is to report a failure when the
> artifact doesn't
>   >  >      exist.)
>   >  >       >
>   >  >       >      Doug

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.