The closest I can think of for this, currently, is the script executor task
plugin. It will allow you to write a shell script there. I'm not a fan of
big scripts in the config, though.

On Mon, Sep 18, 2017 at 1:24 PM, Jeff <[email protected]> wrote:

> As far as I can tell, when wanting to pass environment variable values as
> input to a task, the only way I'm aware of for this to work correctly is to
> use the 'bash -c' command.  For all of my tasks, I'm usually calling Groovy
> scripts and passing command-line options using the 'bash -c' method makes
> for a long and messy looking command.  Here is an example:
>
> <exec command="/bin/bash" workingdir="dbmigration">
>     <arg>-c</arg>
>     <arg>../continuous-deployment/src/OrchestrateFlywayDB.groovy 
> -propertyFile ../materials/pipeline.properties -env $DEPLOY_ENV -user 
> $FLYWAYDB_USER -password $FLYWAYDB_PASSWORD</arg>
>     <runif status="passed" />
> </exec>
>
> It would be really nice if there was a syntax for referencing environment
> variables that GoCD would use to do the environment variable substitution
> (similar to how parameters work) so I can call the tool (e.g., groovy)
> directly instead of wrapping it in a bash call.  Possibly the syntax
> ${MY_ENV} which is similar to parameters.
>
> This would allow the tool to be called directly and the task definition
> would look more like:
>
> <exec command="groovy" workingdir="dbmigration">
>     <arg>../continuous-deployment/src/OrchestrateFlywayDB.groovy</arg>
>     <arg>-propertyFile</arg>
>     <arg>../materials/pipeline.properties</arg>
>     <arg>-env</arg>
>     <arg>${DEPLOY_ENV}</arg>        *//<--ENVIRONMENT substitution by GoCD*
>     <arg>-user</arg>
>     <arg>${FLYWAYDB_USER}</arg>     *//<--ENVIRONMENT substitution by GoCD*
>     <arg>-password</arg>
>     <arg>${FLYWAYDB_PASSWORD}</arg> *//<--ENVIRONMENT substitution by GoCD*
>     <runif status="passed" />
> </exec>
>
> Is there a way to do this today that I'm missing?  If not, I've entered Issue
> #3863 <https://github.com/gocd/gocd/issues/3863> in case and wondered
> what the potential is for getting this feature added.
>
> Thanks!
>
> -Jeff
>
> --
> 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.
>

-- 
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