You've got the environment parameters in the bash script itself.
The environment parameter is a parameter to the EXECUTE and SCRIPT
resources e.g.
bash "script with env vars" do
environment( "SOME_KEY" => "SOME_VALUE", "ANOTHER_KEY" => "ANOTHER_VALUE" )
code <<-EOH
echo 'Env dump'
env
echo 'Env dumped'
env SOME_KEY
env ANOTHER_KEY
echo 'specific keys dumped'
EOH
end
As for whether Maven will honor this, I don't know, but it's trivial
to test that Chef can pass environment variables into a new process --
and this definitely does work.
Cheers,
AJ
On 15 May 2013 08:18, Mark H. Nichols chef@zanshin.net wrote:
On May 10, 2013, at 5:46 PM, AJ Christensen aj@junglist.gen.nz wrote:
Try the 'environment' parameter to the bash script resource (it's
actually from the Execute resource, but this inherits that)
bash 'foo' do
environment 'MAVEN_OPTS' => '-Xms1024m -Xmx2048m -XX:MaxPermSize=500m'
end
I added the "environment" setting to my recipe, resulting in this code:
bash "mvn install -DskipTests" do
code <<-EOH
environment 'MAVEN_OPTS' => '-Xms1024m -Xmx2048m -XX:MaxPermSize=500m'
environment 'JAVA_OPTS' => '-Xms1024m -Xmx2048m -XX:MaxPermSize=512m
-noverify'
cd /home/vagrant/src/jbossas
/usr/local/maven3/bin/mvn install -DskipTests -Dcheckstyle.skip=true
EOH
end
However, I'm still getting a Java Heap space error.
[INFO] BUILD FAILURE
[INFO]
[INFO] Total time: 2:01.567s
[INFO] Finished at: Tue May 14 20:13:36 UTC 2013
[INFO] Final Memory: 105M/121M
[INFO]
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(default-compile) on project jboss-as-clustering-infinispan: Fatal error
compiling: Error while executing the compiler. InvocationTargetException:
Java heap space -> [Help 1]
From the output it appears that the "environment" setting is not working, as
the memory is shown as 121M and not the 1024M minimum asked for.
Is it not possible to use Maven to build something during a Chef run?
etc.
Maybe consider structuring it a little different as well? Write a
shell script or similar, included in your code-base which wraps your
'mvn install', then just run that from Chef. That way you can re-run
or developers could run it if you're hooning around by hand anyway.
Just a thought
Ultimately I'd like to have two recipes in the cookbook. One to install a
pre-built JBoss AS 7.1.3 binary, and a second one to build it on the fly.
The second one would all developers to tweak the build to add or remove
debugging options as needed. I am using :shell provisioning elsewhere in my
setup. I'm not convinced that using that method would get around this
problem however.
-- Mark