General Discussion

General discussion on using Go including questions and tips

This is a public Discussion Area  publicRSS

Post

    Jebastine Vetharaj
    Using env variable in artifact src
    Post posted December 13, 2011 by Jebastine Vetharaj, last edited February 9, 2012
    773 Views, 5 Comments
    Topic:
    Using env variable in artifact src
    Body:

    I would like to use the environment variable in the artifact src property

        <environmentvariables>
            <variable name="UTC_PRJ_PATH">code\MyProject</variable>

    </environmentvariables>

    Below syntax is not working

                    <artifacts>
                        <test src="${UTC_PRJ_PATH}/result/test_results.xml" dest="test-reports" />
                    </artifacts>

    Comment

     

    • Ian Bridson
      posted December 14, 2011 by Ian Bridson

      Hi Jebastine

      I think the ${...} syntax is for Parameters, Environment variables have a %variable% syntax, so it might be worth trying %UTC_PRJ_PATH%.

      Ian

    • Jebastine Vetharaj
      posted December 14, 2011 by Jebastine Vetharaj

      I tried it, it is not working. I would like to scripts in way that the artifacts location is dynamic. Any Idea?

    • Mark Chang
      posted December 14, 2011 by Mark Chang

      Hi Jebastine,

      Instead of using a Go Environment Variable, use a Go Parameter.  Give that a go and let us know if that doesn't work.

      Thanks. 

      --Mark

    • Russell Teabeault
      posted January 25, 2012 by Russell Teabeault

      So then how do you make the parameter dynamic?  If I use the GO_PIPELINE_NAME and GO_PIPELINE_COUNTER to generate the name for an artifact in stage1.  It would look something like <GO_PIPELINE_NAME>-<GO_PIPELINE_COUNTER>.war.  And then in stage2 I want to do a fetch artifact to grab this particular artifact.  However, I can not determine how I could use a parameter to do this.  I can't access the environment variable in <fetchartifact>.  So how would I tell <fetchartifact> the dynamically generated name of this artifact?  Is this even currently possible?

      Thanks,

      -russ

    • goley
      posted January 31, 2012 by goley

      Hi Russell,

      Answer to your first few queries:

      Parameters are not really meant to be dynamic. They are a part of your configuration and can be used to customize/simplify the pipeline configuration.

      GO_PIPELINE_NAME and GO_PIPELINE_COUNTER are environment variables and cannot be used as parameters.

         " So how would I tell <fetchartifact> the dynamically generated name of this artifact?  Is this even currently possible?"

      No, this is not currently possible. 

      Just as a suggestion, when you define a fetchArtifact task to fetch artifact from PipelineA-StageA-JobA, then it will always pick it up from the the latest run of PipelineA-StageA-JobA. So you could fetch the whole folder which cotains your artifact too.