Git Publisher: EnvVar in tag name

818 views
Skip to first unread message

Sverre Moe

unread,
May 4, 2015, 4:26:05 AM5/4/15
to jenkins...@googlegroups.com
I am trying to use Git Publisher to create a git tag, but I cannot get it to use an Environment variable in the tag name:

Is it even possible to supply an Environment Variable as part of a Git tag name?

 > git tag -l v$VERSION # timeout=10
 > git tag -a -f -m Jenkins Git plugin tagging with v$VERSION v$VERSION # timeout=10
Pushing tag v$VERSION to repo origin
 > git --version # timeout=10
 > git -c core.askpass=true push ssh://g...@git.company.com/packages/myLib.git v$VERSION
ERROR: Failed to push tag v$VERSION to origin
hudson.plugins.git.GitException: Command "git -c core.askpass=true push ssh://g...@git.company.com/packages/myLib.git v$VERSION" returned status code 1:
stdout: 
stderr: remote: invalid characters in ref or filename: refs/tags/v$VERSION        
remote: error: hook declined to update refs/tags/v$VERSION        
 ! [remote rejected] v$VERSION -> v$VERSION (hook declined)
error: failed to push some refs to 'ssh://g...@git.company.com/packages/myLib.git'

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1591)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1379)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:86)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$7.execute(CliGitAPIImpl.java:1663)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:152)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:145)
at hudson.remoting.UserRequest.perform(UserRequest.java:121)
at hudson.remoting.UserRequest.perform(UserRequest.java:49)
at hudson.remoting.Request$2.run(Request.java:325)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
at ......remote call to Development-openSUSE-x86_64(Native Method)
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1360)
at hudson.remoting.UserResponse.retrieve(UserRequest.java:221)
at hudson.remoting.Channel.call(Channel.java:753)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:131)
at com.sun.proxy.$Proxy87.execute(Unknown Source)
at hudson.plugins.git.GitPublisher.perform(GitPublisher.java:306)
at hudson.plugins.git.GitPublisher$1.endBuild(GitPublisher.java:147)
at hudson.matrix.MatrixBuild$MatrixBuildExecution.post2(MatrixBuild.java:407)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:670)
at hudson.model.Run.execute(Run.java:1766)
at hudson.matrix.MatrixBuild.run(MatrixBuild.java:306)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:374)


Sverre Moe

unread,
May 5, 2015, 2:47:32 AM5/5/15
to jenkins...@googlegroups.com
I can create a Git tag using other environment variables such as BUILD_TAG, but why isn't my own environment variables available during the publish stage. My own environment variables are available during the build stage.

Sverre Moe

unread,
May 5, 2015, 2:58:14 AM5/5/15
to jenkins...@googlegroups.com
Something strange:
I am using Inject Environment Variables, "Inject environment variables to the following build steps and post-build actions".
The variables injected from a "Properties File" are not accessible during the post-build phase, but those I declare within "Properties Content" are.

Sverre Moe

unread,
May 5, 2015, 3:16:23 AM5/5/15
to jenkins...@googlegroups.com
I found the reason, but still not the solution.

My projects are Multi-configuration jobs. My injected environment variables are available during both build and post-build, for each matrix axis, but not the matrix parent. The Git Publisher works on the matrix parent, and it seems like the environment variables are not available there.

How can I get the Matrix parent to also get the environment variables?

Sverre Moe

unread,
May 5, 2015, 4:59:15 AM5/5/15
to jenkins...@googlegroups.com
It seems there is an registered JIRA issue for this problem

Its 3 years old, it has not been fixed, nor updated for a year.

Sverre Moe

unread,
May 6, 2015, 11:03:48 AM5/6/15
to jenkins...@googlegroups.com
Anyone has any idea how I can get my build environment variables over to the matrix parent?
Reply all
Reply to author
Forward
0 new messages