Closed logiclrd closed 6 years ago
Okay, I have done more investigation and discovered that Albacore overrides Ruby's system
with its own (in cross_platform_cmd.rb
). Its override raises an exception if anything is sent to stderr
. So, that explains how build failures are normally caught (though the fact that it is redefining a core function with the same name is a bit confusing; it isn't immediately obvious at the call site that it isn't using the standard system
function).
This still leaves unexplained the fact that the build system didn't detect a failure, but that might be out of scope for Albacore, because the build output is in fact showing a stack trace for an unhandled exception, even though the build ends up still being reported a success. Time to try to find some unneeded rescue
block I guess... :-)
Hello :-) I'm writing this here because I figure there'll be some people with excellent domain knowledge reading it. I'm still learning about Ruby and Rake tasks.
What I'm trying to figure out is, how are build failures detected? I did some snooping, and I see that
Albacore::Build::Cmd
just callssystem
on the command-line it has built up. This means that that line will have atrue
return value for a 0 exit code andfalse
otherwise -- so a failed build will returnfalse
. Thisfalse
value gets propagate back up to the level of the Rake task. But, then I looked into how Rake invokes tasks, and from the source code I saw in the Rake documentation, it looks like it completely ignores return values. They get subsumed in a block passed to@actions.each
, and the return value of@actions.each
seems to be@actions
itself. So, Rake tasks do not have return values.Where in this flow, then, does a build error get detected? Should Albacore be throwing an exception when
system
returnsfalse
? Or is there some underlying mechanic I'm completely missing that already detects build failures in this circumstance?What set me on this journey is that I have another project that must invoke multiple different builds from within a single build definition. To do that, I use statements such as this:
The
:msbuild
task in this case is a task defined using Albacore'sbuild
DSL. All it does is copy parameters from the:project_variables
passed into it into theAlbacore::Build::Cmd
configuration object that thebuild
DSL passes in.In my build output, what I am seeing is that Albacore is successfully launching MSBuild, and then MSBuild is emitting errors (due to a configuration problem in the environment) -- but the build isn't being detected as a failure. The Ruby script is returning successfully at the top level, and the build is green in our automation software.
What am I overlooking here?