[JIRA] [git-plugin] (JENKINS-30287) Environment variables are not expanded in tag names when publishing

37 views
Skip to first unread message

dancrumb@gmail.com (JIRA)

unread,
Sep 3, 2015, 2:24:02 PM9/3/15
to jenkinsc...@googlegroups.com
Dan Rumney created an issue
 
Jenkins / Bug JENKINS-30287
Environment variables are not expanded in tag names when publishing
Issue Type: Bug Bug
Assignee: Nicolas De Loof
Components: git-plugin
Created: 03/Sep/15 6:23 PM
Environment: System Properties

Name ↓
Value
executable-war /usr/lib/jenkins/jenkins.war
file.encoding UTF-8
file.encoding.pkg sun.io
file.separator /
hudson.diyChunking true
java.awt.graphicsenv sun.awt.X11GraphicsEnvironment
java.awt.headless true
java.awt.printerjob sun.print.PSPrinterJob
java.class.path /usr/lib/jenkins/jenkins.war
java.class.version 50.0
java.endorsed.dirs /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/endorsed
java.ext.dirs /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/ext:/usr/java/packages/lib/ext
java.home /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre
java.io.tmpdir /tmp
java.library.path /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/amd64/server:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/amd64:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
java.protocol.handler.pkgs org.apache.axis.transport|
java.runtime.name OpenJDK Runtime Environment
java.runtime.version 1.6.0_33-b33
java.specification.name Java Platform API Specification
java.specification.vendor Sun Microsystems Inc.
java.specification.version 1.6
java.vendor Sun Microsystems Inc.
java.vendor.url http://java.sun.com/
java.vendor.url.bug http://java.sun.com/cgi-bin/bugreport.cgi
java.version 1.6.0_33
java.vm.info mixed mode
java.vm.name OpenJDK 64-Bit Server VM
java.vm.specification.name Java Virtual Machine Specification
java.vm.specification.vendor Sun Microsystems Inc.
java.vm.specification.version 1.0
java.vm.vendor Sun Microsystems Inc.
java.vm.version 23.25-b01
javamelody.About Monitoring https://wiki.jenkins-ci.org/display/JENKINS/Monitoring
javamelody.analytics-id UA-1335263-7
javamelody.custom-reports Jenkins Info,About Monitoring
javamelody.gzip-compression-disabled true
javamelody.http-transform-pattern /\d+/|/site/.+|avadoc/.+|/ws/.+|obertura/.+|estReport/.+|iolations/file/.+|/user/.+|/static/\w+/|/adjuncts/\w+/|/bound/[\w\-]+
javamelody.Jenkins Info /systemInfo
javamelody.no-database true
javamelody.storage-directory //srv/jenkins/monitoring
javamelody.system-actions-enabled true
JENKINS_HOME /srv/jenkins
jna.platform.library.path /usr/lib64:/lib64:/usr/lib:/lib
jnidispatch.path /tmp/jna--1712433994/jna852656259792851681.tmp
line.separator
mail.smtp.sendpartial true
mail.smtps.sendpartial true
os.arch amd64
os.name Linux
os.version 3.14.20-20.44.amzn1.x86_64
path.separator :
pid 1195
sun.arch.data.model 64
sun.boot.class.path /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/resources.jar:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/rt.jar:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/jsse.jar:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/jce.jar:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/jfr.jar:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/netx.jar:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/plugin.jar:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/rhino.jar:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/classes
sun.boot.library.path /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/amd64
sun.cpu.endian little
sun.cpu.isalist
sun.io.unicode.encoding UnicodeLittle
sun.java.command /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --httpPort=8080 --ajp13Port=8009 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20 --prefix=/jenkins
sun.java.launcher SUN_STANDARD
sun.jnu.encoding UTF-8
sun.management.compiler HotSpot 64-Bit Tiered Compilers
sun.os.patch.level unknown
svnkit.http.methods Digest,Basic,NTLM,Negotiate
svnkit.ssh2.persistent false
user.country US
user.dir /
user.home /srv/jenkins
user.language en
user.name jenkins
user.timezone Universal
Environment Variables

Name ↓
Value
_ /etc/alternatives/java
CONSOLETYPE serial
GEM_PATH file:/srv/jenkins/plugins/ruby-runtime/WEB-INF/lib/stapler-jruby-1.209.jar!/gem
HOME /srv/jenkins
LANG en_US.UTF-8
LANGSH_SOURCED 1
LD_LIBRARY_PATH /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/amd64/server:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/lib/amd64:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.33.x86_64/jre/../lib/amd64
LOGNAME jenkins
NLSPATH /usr/dt/lib/nls/msg/%L/%N.cat
PATH /sbin:/usr/sbin:/bin:/usr/bin
previous N
PREVLEVEL N
PWD /
RUNLEVEL 3
SHELL /bin/bash
SHLVL 3
TERM linux
UPSTART_EVENTS runlevel
UPSTART_INSTANCE
UPSTART_JOB rc
USER jenkins
XFILESEARCHPATH /usr/dt/app-defaults/%L/Dt
Plugins

Name ↓
Version
Enabled
Pinned
ansicolor 0.4.0 true false
ant 1.2 true false
antisamy-markup-formatter 1.3 true true
awseb-deployment-plugin 0.0.3 true false
build-pipeline-plugin 1.4.4 true false
cluster-stats 0.4.5 true false
codedeploy 1.3 true false
configurationslicing 1.41 true false
copyartifact 1.35 true false
credentials 1.22 true true
cvs 2.12 true true
diffplugin 1.4 true false
disk-usage 0.24 true false
external-monitor-job 1.2 true false
git 2.3 true false
git-client 1.18.0 true false
gravatar 2.1 true false
greenballs 1.14 true false
javadoc 1.2 true true
jira 1.41 true false
jquery 1.7.2-1 true false
junit 1.1 true true
ldap 1.11 true true
mailer 1.15 true true
mapdb-api 1.0.6.0 true false
matrix-auth 1.2 true true
matrix-project 1.4 true true
maven-plugin 2.7.1 true true
monitoring 1.53.1 true false
multiple-scms 0.3 true false
next-build-number 1.1 true false
nodejs 0.2.1 true false
pam-auth 1.2 true true
Parameterized-Remote-Trigger 2.1.3 true false
parameterized-trigger 2.25 true false
PrioritySorter 3.4 true false
ruby-runtime 0.12 true false
rvm 0.4 true false
s3 0.7 true false
scm-api 0.2 true false
simple-theme-plugin 0.3 true false
slack 1.8 true false
ssh-credentials 1.11 true true
ssh-slaves 1.8 true true
stashNotifier 1.6 true false
subversion 2.4.4 true true
token-macro 1.10 true false
translation 1.12 true true
windows-slaves 1.0 true false
ws-cleanup 0.25 true false
Labels: plugin
Priority: Major Major
Reporter: Dan Rumney

I'm using the Git Publisher post-build action to try and push a tag that was created during the build.

The tag name is placed into an environment variable via the line:

export BUILD_VERSION=`node -e "console.log(require('./package.json').version);"`

The Git Publisher is then configured to push the Tag $BUILD_VERSION

Rather than push it, I get an error in my build console:

   > git tag -l $BUILD_VERSION # timeout=10
ERROR: Publisher hudson.plugins.git.GitPublisher aborted due to exception
hudson.AbortException: Tag $BUILD_VERSION does not exist and Create Tag is not specified, so failing.
	at hudson.plugins.git.GitPublisher.perform(GitPublisher.java:287)
	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
	at hudson.model.Build$BuildExecution.post2(Build.java:183)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
	at hudson.model.Run.execute(Run.java:1784)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:89)
	at hudson.model.Executor.run(Executor.java:240)
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.2#64017-sha1:e244265)
Atlassian logo

dancrumb@gmail.com (JIRA)

unread,
Sep 3, 2015, 2:41:01 PM9/3/15
to jenkinsc...@googlegroups.com
Dan Rumney commented on Bug JENKINS-30287
 
Re: Environment variables are not expanded in tag names when publishing

Line 268 of GitPublisher.java is:

                    final String tagName = environment.expand(t.getTagName());

which indicates that this should work... however, I wonder whether environment includes variables added during the build.

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

unread,
Sep 3, 2015, 5:12:01 PM9/3/15
to jenkinsc...@googlegroups.com

Could you review

JENKINS-24786 to see if there is useful information in that bug report which might help you?

mattias.vannergard@gmail.com (JIRA)

unread,
Nov 13, 2015, 6:25:02 AM11/13/15
to jenkinsc...@googlegroups.com

This is not a problem with Git plugin. This is a common problem, that makes build environment variables be gone at Post-Build actions.

What you need to do is to export the variable to a temporary file, and re-read this file into environment as the first of Post-Build Actions.

In the Build section:
echo <your variable>=%<your variable>% > temp.var

In the Post-Build section, add "Execute a set of scripts" => Build steps => Inject environment variables.
Set Properties File Path to temp.var

jenkins@bo3b.net (JIRA)

unread,
May 2, 2016, 6:43:01 AM5/2/16
to jenkinsc...@googlegroups.com

Thought I'd update this bug with current status. I'm also seeing this problem on the latest beta of 2.5.0-beta5.

No regular environment variables are expanded. I'm not certain that it is only the Post-Build shell being different, because if I create a post-build task and set environment variables there, then they are still ignored/lost by Git Publisher.

If I use the Inject Environment variables plugin, I can save the variables into a file in the normal build, then load them at post-build with Inject Environment variables. The variables appear to be read properly, but only the last variable in the file is available for expansion.

So... a workaround I can use for now is to put a full version string into a single variable, Inject that variable at post-build, and then I can use that single variable in Git Publisher to Tag the version.

nicolas.deloof@gmail.com (JIRA)

unread,
Apr 24, 2019, 10:29:28 AM4/24/19
to jenkinsc...@googlegroups.com
Nicolas De Loof assigned an issue to Unassigned
 
Change By: Nicolas De Loof
Assignee: Nicolas De Loof
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)
Reply all
Reply to author
Forward
0 new messages