Using Environment variables in Workflow

74 views
Skip to first unread message

pallen

unread,
Sep 9, 2015, 1:09:30 PM9/9/15
to Jenkins Developers
Hi Guys,

There seems to be an issues accessing the Environment variables from the 'p4' plugin?

node {
   p4sync charset: 'none', credential: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx', depotPath: '//depot'
   echo env.P4_CHANGELIST
   echo env.JOB_NAME
}

JOB_NAME gets displayed, but P4_CHANGELIST is null?  However, with the Freestyle Job both are available.

Is this a 'scope' issue? Do I need to do something more than assign them in buildEnvVars():


Kind regards,
Paul

pallen

unread,
Sep 9, 2015, 1:21:48 PM9/9/15
to Jenkins Developers
Looking at the SCM class:

    // TODO is an equivalent for Run needed?


    public void buildEnvVars(AbstractBuild<?,?> build, Map<String, String> env) {


        // default implementation is noop.


    }


The TODO suggests that something is missing for Run/Workflow!

Jesse Glick

unread,
Sep 9, 2015, 5:29:50 PM9/9/15
to Jenkins Dev
On Wed, Sep 9, 2015 at 1:21 PM, pallen <pal...@perforce.com> wrote:
> The TODO suggests that something is missing for Run/Workflow!

https://issues.jenkins-ci.org/browse/JENKINS-24141

Is `p4sync` just extending `SCMStep`?

Paul Allen

unread,
Sep 10, 2015, 9:17:32 AM9/10/15
to jenkin...@googlegroups.com
Hi Jesse,

Yes, it extends SCMStep…

https://github.com/jenkinsci/p4-plugin/blob/master/src/main/java/org/jenkinsci/plugins/p4/workflow/P4Step.java#LC24

I added two break points in SCM.buildEnvVars and my own buildEnvVars and neither get hit during a Workflow build.

I’ll do a bit of hacking, but let me know if you have any thoughts.

Kind regards,
Paul
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2p2VzO6w2i-M-OBpwXBU%2Bf3-9TjQ7F%2B0j4qmW4VrAAEg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--------------------------------------------------------------------------------
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed. If
you have received this email in error please notify the system manager. Please
note that any views or opinions presented in this email are solely those of the
author and do not necessarily represent those of Perforce Software. Finally,
the recipient should check this email and any attachments for the presence of
viruses. Perforce Software accepts no liability for any damage caused by any
virus transmitted by this email.

Perforce Software UK Ltd is registered in England and Wales as company no.
3816019 at the following address: West Forest Gate, Wellington Road, Wokingham,
RG40 2AT, UK
--------------------------------------------------------------------------------

Jesse Glick

unread,
Sep 10, 2015, 1:10:48 PM9/10/15
to Jenkins Dev
On Thu, Sep 10, 2015 at 9:17 AM, Paul Allen <pal...@perforce.com> wrote:
> I added two break points in SCM.buildEnvVars and my own buildEnvVars and neither get hit during a Workflow build.

Of course not; pending JENKINS-24141 the API does not permit an SCM to
contribute environment variables to Workflow.
Reply all
Reply to author
Forward
0 new messages