Using GoCD v16.3.0.

I normally call groovy scripts in the form:

<exec command="
*../continuous-deployment/wp-groovy/src/gocd/OrchestratePipelineMaterialsUpdate.groovy*"
workingdir="salt-pillars">
<arg>-src</arg>
<arg>bcisresponders/appattribute</arg>
<arg>-dest</arg>
<arg>../appattribute_materials/pillar</arg>
<arg>-updateGit</arg>
<runif status="passed" />
</exec>


Normally this works, but for some of my scripts I need to pass in
environment variables (both secure and standard) defined in the GoCD
Environments on the command-line.

Calling the groovy script using the above pattern does not process the
environment variable substitution before calling Groovy so wrapping in a
shell call is necessary.

However, even the format to call this is non-intuitive because passing the
command + arguments using the 'bash -c' method requires all arguments be
passed in on one single line.  For example, the following causes an error:

<exec command="/bin/bash" workingdir="dbmigration">
<arg>-c</arg>
<arg>../continuous-deployment/wp-groovy/src/gocd/OrchestrateFlywayDB.groovy</arg>
<arg>-propertyFile</arg>
<arg>../materials/pipeline.properties</arg>
<arg>-env</arg>
<arg>#{DEPLOY_ENV}</arg>
<arg>-user</arg>
<arg>$FLYWAYDB_USER</arg>
<arg>-password</arg>
<arg>$FLYWAYDB_PASSWORD</arg>
<runif status="passed" />
</exec>


The above must be changed to a single argument as shown below for it to
work properly:

<exec command="/bin/bash" workingdir="dbmigration">
<arg>-c</arg>
<arg>../continuous-deployment/wp-groovy/src/gocd/OrchestrateFlywayDB.groovy
-propertyFile ../materials/pipeline.properties -env #{DEPLOY_ENV} -user
$FLYWAYDB_USER -password $FLYWAYDB_PASSWORD</arg>
<runif status="passed" />
</exec>


It would sure be nice to have a mechanism independent from the shell but
instead is pre-processed by GoCD before calling the command.  Something
similar to the #{...} parameters but for environment variables.

Is there a way to do this that I'm missing?

Thanks!

-- 
Jeff Vincent
See my LinkedIn profile at:
http://www.linkedin.com/in/rjeffreyvincent

-- 
You received this message because you are subscribed to the Google Groups 
"go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to