[JIRA] (JENKINS-36436) Environment variables are always NULL

5 views
Skip to first unread message

haddad.said@gmail.com (JIRA)

unread,
Jul 5, 2016, 7:06:01 AM7/5/16
to jenkinsc...@googlegroups.com
Haddad Said created an issue
 
Jenkins / Bug JENKINS-36436
Environment variables are always NULL
Issue Type: Bug Bug
Assignee: Mark Waite
Components: git-plugin
Created: 2016/Jul/05 11:05 AM
Environment: Jenkins 2.8
Git plugin 2.5.2
Git client plugin 1.19.6
Priority: Major Major
Reporter: Haddad Said

The environment variables documented here https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-AdvancedFeaturesorigin%2Fmaster are always NULL

Example script
{{
node (){
echo "$

{env.PATH}

";
git branch: 'develop', credentialsId: 'xxxxx', url: 'g...@xxx.com:org/repo.git'
echo "$

{env.GIT_BRANCH}

";
echo "$

{env.GIT_URL}

";
echo "$

{env.JAVA_HOME}

";
echo "$

{env.NODE_NAME}

";
echo "$

{env.JOB_NAME}

";
}}}

Produces this output in the console

Started by user xxxx
[Pipeline] node
Running on xxxx in /home/jenkagent01/jenkinsroot/workspace/pipeline-example
[Pipeline] {
[Pipeline] echo
/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin
[Pipeline] git
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url xxxxx # timeout=10
Fetching upstream changes from xxxx
> git --version # timeout=10
using GIT_SSH to set credentials
> git -c core.askpass=true fetch --tags --progress git@xxxx +refs/heads/:refs/remotes/origin/
> git rev-parse refs/remotes/origin/develop^

{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/develop^{commit}

# timeout=10
Checking out Revision b4d38494c725ccbdc1d66a68a31eb65eb23b3dae (refs/remotes/origin/develop)
> git config core.sparsecheckout # timeout=10
> git checkout -f b4d38494c725ccbdc1d66a68a31eb65eb23b3dae # timeout=10
> git branch -a -v --no-abbrev # timeout=10
> git branch -D develop # timeout=10
> git checkout -b develop b4d38494c725ccbdc1d66a68a31eb65eb23b3dae
> git rev-list b4d38494c725ccbdc1d66a68a31eb65eb23b3dae # timeout=10
[Pipeline] echo
null
[Pipeline] echo
null
[Pipeline] echo
null
[Pipeline] echo
xxxxx
[Pipeline] echo
pipeline-example
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

Searching only leads me to this which seems like a hack -> https://github.com/jenkinsci/pipeline-examples/blob/master/pipeline-examples/gitcommit/gitcommit.groovy

For example http://stackoverflow.com/questions/35554983/git-variables-in-jenkins-workflow-plugin

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 5, 2016, 2:01:02 PM7/5/16
to jenkinsc...@googlegroups.com
Mark Waite assigned an issue to Unassigned
Change By: Mark Waite
Assignee: Mark Waite

cleclerc@cloudbees.com (JIRA)

unread,
Jan 16, 2017, 11:56:03 AM1/16/17
to jenkinsc...@googlegroups.com
Cyrille Le Clerc updated an issue
Change By: Cyrille Le Clerc
The environment variables documented here https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-AdvancedFeaturesorigin%2Fmaster are always NULL

Example script
{ { code}
node (){
    echo "${env.PATH}";
    git branch: 'develop', credentialsId: 'xxxxx', url: 'g...@xxx.com:org/repo.git'
    echo "${env.GIT_BRANCH}";
    echo "${env.GIT_URL}";
    echo "${env.JAVA_HOME}";
    echo "${env.NODE_NAME}";
    echo "${env.JOB_NAME}";
}

{code
} }

Produces this output in the console


{noformat}
Started by user xxxx
[Pipeline] node
Running on xxxx in /home/jenkagent01/jenkinsroot/workspace/pipeline-example
[Pipeline] {
[Pipeline] echo
/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin
[Pipeline] git
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url xxxxx # timeout=10
Fetching upstream changes from xxxx
> git --version # timeout=10
using GIT_SSH to set credentials
> git -c core.askpass=true fetch --tags --progress git@xxxx +refs/heads/*:refs/remotes/origin/*

> git rev-parse refs/remotes/origin/develop^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/develop^{commit} # timeout=10
Checking out Revision b4d38494c725ccbdc1d66a68a31eb65eb23b3dae (refs/remotes/origin/develop)
> git config core.sparsecheckout # timeout=10
> git checkout -f b4d38494c725ccbdc1d66a68a31eb65eb23b3dae # timeout=10
> git branch -a -v --no-abbrev # timeout=10
> git branch -D develop # timeout=10
> git checkout -b develop b4d38494c725ccbdc1d66a68a31eb65eb23b3dae
> git rev-list b4d38494c725ccbdc1d66a68a31eb65eb23b3dae # timeout=10
[Pipeline] echo
null
[Pipeline] echo
null
[Pipeline] echo
null
[Pipeline] echo
xxxxx
[Pipeline] echo
pipeline-example
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
{noformat}

cleclerc@cloudbees.com (JIRA)

unread,
Jan 16, 2017, 11:57:02 AM1/16/17
to jenkinsc...@googlegroups.com
Cyrille Le Clerc commented on Bug JENKINS-36436
 
Re: Environment variables are always NULL

Note: I humbly edited the ticket and used {code} and {noformat} to ease readibility

jglick@cloudbees.com (JIRA)

unread,
Feb 15, 2017, 11:53:12 AM2/15/17
to jenkinsc...@googlegroups.com
Jesse Glick resolved as Duplicate
 
Change By: Jesse Glick
Status: Open Resolved
Resolution: Duplicate

mark.earl.waite@gmail.com (JIRA)

unread,
Oct 22, 2019, 9:34:24 PM10/22/19
to jenkinsc...@googlegroups.com
Mark Waite closed an issue as Duplicate
Change By: Mark Waite
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages