Name |
Pre/Post Build Command Plugin |
---|---|
Version |
2.4.0 |
Product Versions |
2.2.x , 2.3.x, 2.4.x |
Author(s) |
Jonathan Doklovic [developer(at)sysbliss(dot)com] |
Homepage |
|
Price |
Free |
License |
|
JavaDocs |
|
IssueTracking |
|
Subversion URL |
https://svn.atlassian.com/svn/public/contrib/bamboo/bamboo-prepostcommand-plugin or browse via fisheye |
Download JAR |
|
2.1.x compatible |
|
2.2.x compatible |
|
2.3 compatible |
Configuration Change
Since version 2.2.0 all commands pre AND post are configured on the builder screen.
Post commands are no longer on the Post Actions screen.
Description/Features
This plugin can run an arbitrary command before a build runs or when a build passes or fails.
The pre command is specified on the Builder Configuration page.
The post commands are also specified on the Builder Configuration configuration page.
Ability to specify if commands run in the bamboo build thread or in their own spawned thread
Sysout and Syserr from the command are logged to the bamboo.log file.
Sysout and Syserr also go to the build log in the web interface if a pre command runs in the bamboo thread.
since 2.2.0 Ability to specify if commands run on the server or on the agent
Usage
Installation Change
Since version 2.4.0 the plugin should now be installed into BAMBOO_HOME/plugins
Post commands are no longer on the Post Actions screen.
- Download and install the plugin into your Bamboo WEB-INF/lib folder (see note above)
- Select your build and edit the Builder Configuration under the Configuration tab.
- Enter the complete command line to run before the build in the Command field.
- Select your build and edit the Builder under the Configuration tab.
- Enter the complete command line(s) to run in the Success and Failed Command fields
- After each build, the system will run either the Success or Failed command as appropriate if it's filled in
Configuration Details
Each command field will expand ALL global and custom variables including:
property |
description |
---|---|
${bamboo.buildKey} |
the build key. (i.e. PRJ-PLAN) |
${bamboo.buildNumber} |
the build number. (i.e. 14) |
${bamboo.fullBuildKey} |
the full build key. (i.e. PRJ-PLAN-14) |
${bamboo.buildResultsUrl} |
the build results url |
${bamboo.projectBaseDir} |
the project base dir (i.e. checkout dir) |
Screenshots
Screenshots |
|
---|---|
17 Comments
Eric Jain
Doesn't seem to be working with Bamboo 2.x?
jonathan doklovic
The current version is only for 1.2.4.
I will be adding 2.0 support either today or tomorrow.
jonathan doklovic
2.0 compatible version now available version
Ben Gamble
This is probably some simple user error, but I'm running plugin version 2.0.1 with bamboo v2.0.4 and the post command simply doesn't run after a successful build. Log snippets:
simple 12-Aug-2008 15:01:04 Executing build PLAT-NIGHTLY-59
simple 12-Aug-2008 15:01:04 Running pre-build action: Build Number Stamper
simple 12-Aug-2008 15:01:04 Running pre-build action: VCS Version Collector
simple 12-Aug-2008 15:01:04 Running pre-build action: Pre Command Runner
simple 12-Aug-2008 15:01:04 Building started with ScriptBuilder
command 12-Aug-2008 15:01:04 Starting to build 'Platform - Nightly'<br /> ... running command line: /bin/sh build-script all<br /> ... in : /a/Bamboo/xml-data/build-dir/PLAT-NIGHTLY<br /> ... using java: null<br /> ... using environment variables:
build 12-Aug-2008 15:01:04 /a/Bamboo/xml-data/build-dir/PLAT-NIGHTLY
[...]
build 12-Aug-2008 15:01:19 ...found 484 target(s)...
simple 12-Aug-2008 15:01:19 Build process for 'Platform - Nightly' returned with return code = 0
simple 12-Aug-2008 15:01:19 Running post build plugin 'Artifact Copier'
simple 12-Aug-2008 15:01:19 Running post build plugin 'Clover Results Collector'
simple 12-Aug-2008 15:01:19 Finalising the build...
simple 12-Aug-2008 15:01:19 Stopping timer.
simple 12-Aug-2008 15:01:19 Build PLAT-NIGHTLY-59 completed.
simple 12-Aug-2008 15:01:19 Running post build plugin on server 'Clover Delta Calculator'
I see a "Pre Command Runner" but no hint of any post commands despite the build being successful. Atlassian support made some vague noises about "running my build on an agent" (the agent is local) but had no clue whether that would cause the plugin to run locally or ignore the configured commands or what.
Ben Gamble
nm, found all my commands, conveniently located in a server-level log file totally inaccessible from the web interface.
jonathan doklovic
This is due to the fact that the post command runner plugin is a BuildCompleteAction.
BuildCompleteActions do not log anything to the web interface's build log since they run after the build is finished.
I plan to convert the post command plugin to a BuildProcessor instead of a BuildComplete Action which will allow you to see the output in the web interface, but only if it is running in the Bamboo build thread. In v 2.1 of the plugin, you have the ability to run the command in a separate thread, and in that case, it will not log to the bamboo build log since it's in a separate thread.
Hope that makes sense.
- Jonathan
Bob Swift
Nice plugin . Perhaps this is more of an Atlassian question - is it possible with the pre command to make changes to the build plan attributes that will take effect before the build gets run? For instance, modifying the build plan requirements that may affect what agents can process this instance of the build.
jonathan doklovic
Hey Bob,
With the release of version 2.2.0, you now have the ability to specify if the pre command runs on the server or the agent.
If you tell it to run on the server, the command actually gets run as a PreBuildQueuedAction which runs before the build is queued.
In theory, I believe you should still be able to affect which agent picks up the build at this point by changing the requirements, but I haven't tested this.
Bob Swift
Jonathan, looks like a nice update . Especially the server or agent option. I will have to check it out soon. Now, I just have to figure out how the requirements can be updated by a script. The rest APIs don't deal with that. I suppose tinkering with the database is possible. Perhaps a Bamboo developer can offer a suggestion?
Mads Nissen
Is there a build home dir variable that can be used for simple commands like (on windows):
post-build command:
cmd /c del $
\test-report*.xml
Drew Marold
It would be great if there was a way to specify system variables like the builder does. I'm trying to use this to run my build script with the clean target before running the build so it always builds from a clean start. The problem is the build tool needs certain environment variables defined to find things. It works for the builder because I can pass in what it needs, but not for the prebuild command.
Dustin Chesterman
Seconded!
Mathieu Filotto
I've just tried version 2.3.1 with Bamboo 2.1 but it's not working.
I added a pre command then my build stopped with this log :
Manual build triggered by admin
Jeff Schnitter
I'm getting an error with Bamboo 2.2 and version 2.3.1 of the plugin when I'm running on the agent without running in a separate thread. I get this error:
2009-03-21 10:52:54,218 ERROR :myhost::Agent BuildAgentControllerImpl Unknown error occurred on 'myhost' when building ODODEV-CMS-121. Agent will attempt process the build result...
java.lang.NoClassDefFoundError: org/apache/commons/exec/ExecuteStreamHandler
at com.sysbliss.bamboo.plugins.prepostcmd.runner.AbstractCommandRunner.execCommand(AbstractCommandRunner.java:74)
at com.sysbliss.bamboo.plugins.prepostcmd.runner.AbstractCommandRunner.execute(AbstractCommandRunner.java:56)
at com.sysbliss.bamboo.plugins.prepostcmd.runner.AbstractCommandRunner.run(AbstractCommandRunner.java:49)
at com.sysbliss.bamboo.plugins.prepostcmd.action.PreBuildCommandAgentAction.call(PreBuildCommandAgentAction.java:48)
at com.atlassian.bamboo.build.pipeline.tasks.PrepareBuildTask.call(PrepareBuildTask.java:59)
at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:188)
at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:89)
at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:101)
at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$1.run(NamedThreadFactory.java:32)
at edu.emory.mathcs.backport.java.util.concurrent.helpers.ThreadHelpers$1.run(ThreadHelpers.java:34)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.exec.ExecuteStreamHandler
at com.atlassian.bamboo.agent.bootstrap.AgentClassLoader.findClass(AgentClassLoader.java:137)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at com.atlassian.bamboo.agent.bootstrap.AgentClassLoader.loadClass(AgentClassLoader.java:295)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 11 more
If I run in a separate thread I can't cause the build to fail on an error, which I need to be able to do. Is this a bug, or could it be a configuration
issue on my side?
Jeff Schnitter
Not sure why I'm getting the above error. The class in question, org/apache/commons/exec/ExecuteStreamHandler is packaged in the jar:
40727 Thu Mar 19 11:54:36 PDT 2009 META-INF/lib/commons-exec-1.0-cs-01.jar
I was able to bypass the problem by exploding commons-exec-1.0-cs-01.jar and repackaging prepost-build-command-2.3.1.jar. I don't think this should be necessary, but the plugin was failing otherwise for me.
Chris Hilton
I get the same error with Bamboo 2.2.1 and 2.3.1 of the plugin. I'll probably work around it in the build instead of repackaging the jar as you did above so that I don't have to restart the server. Bummer this didn't work.
Chris Hilton
I ended up repackaging the jar as a backup plan for when we did restart the server and we had the opportunity over the weekend. Now, though, I get the following error when looking at the Builder sub-tab in the Configuration tab for every build:
Builder plugin not found for plan!
Fortunately, I can still edit the plan there, see all the build settings and they seem to be correct; I just can't see them as part of the normal review page.