Jenkins 2.x Pipeline - parametrized build, parameters are not evaluated in Git

1,687 views
Skip to first unread message

thomas....@teamaol.com

unread,
Apr 5, 2016, 3:47:50 AM4/5/16
to Jenkins Users
Hi,

Mode: Pipeline script from SCM

I tried to change working example to take a TAG as String parameter
and to use ${TAG} for the Branch using the Pipeline job in Jenkins 2.x
When trying this I get this:

 > git rev-parse origin/${TAG}^{commit} # timeout=10
 > git rev-parse ${TAG}^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.

It looks to me that the variable TAG is not evaluated. Using "master" instead
of "${TAG}" works fine.

Bug? I guess so.

Kind Regards,
Thomas

PS: I tried to register at Jenkins JIRA but it's a nightmare. Either the captcha popup appears
after hours, or it timeouts or I get null pointer exception after submitting or whatever.
After 20 minutes I gave up. So don't ask me to write a ticket please ;)

Björn Pedersen

unread,
Apr 5, 2016, 7:36:48 AM4/5/16
to Jenkins Users
Hi,

 yes, I can confirm that behaviour. Taking a closer look at the log shows that any build wrappers that inject e.g. Environment vars are not running at this early stage.
My guess is, that the assumption was that these wrappers are instantiated in the Jenkinsfile, so that they are not yet known.

Wether this is a good assumption in all use-cases is an open question.

Björn

thomas....@teamaol.com

unread,
Apr 6, 2016, 2:10:09 AM4/6/16
to Jenkins Users
Just to clarify:
The variable is required before using the content of the repository.
That's true for the normal use of the Git plugin and also documented
looking at the question icon (in both cases, normal and the pipeline variant)

The text:
  • ${ENV_VARIABLE}
    It is also possible to use environment variables. In this case the variables are evaluated and the result is used as described above.
    E
    .g. ${TREEISH}, refs/tags/${TAGNAME},...

I think it is also logical. I would like to run a pipeline on "git master" to deploy into production.
But I also need to be able to run the pipeline for a feature branch (which ends after the regression tests).

Kind Regards,
Thomas

thomas....@teamaol.com

unread,
Apr 8, 2016, 3:06:59 AM4/8/16
to Jenkins Users
I tested that with the first release candidate.
The issue is still there!

Lionel Orellana

unread,
May 1, 2016, 8:19:17 AM5/1/16
to Jenkins Users
Doesn't the Pipeline Multibranch Plugin do what you want? Still sounds like a bug though.

thomas....@teamaol.com

unread,
May 10, 2016, 6:05:50 AM5/10/16
to Jenkins Users
The multibranch is for sure something I will look into it but the mentioned behavior is
someting that has been working with Freestyle (as example). So yes .... agree ... sounds like a bug.

Francois Marot

unread,
Jul 26, 2016, 5:06:30 PM7/26/16
to Jenkins Users
Has anyone any update or workaround on it ?
I'd like to move the team to Jenkins 2 and use Jenkinsfile but not being able to run a build against a specific branch or a specific commit is a blocker in my case... I need to be able to build again old versions of my software.
I tried yesterday on up to date Jenkins and it is still KO

Regards, Francois

Greg Smith

unread,
Jul 26, 2016, 8:28:21 PM7/26/16
to Jenkins Users
We are currently using the multibranch plugin to rebuild old versions of our code using Jenkins 2.X pipeline style.

Our main branch just uses "checkout scm".  That builds and builds.

If we need to rebuild an old release, from a specific version, we create a branch from that version:
git branch oldversion1.2.3 <tag>

Now push that to your repo, and the multibranch plugin finds that branch, and rebuilds the old code.

Cheers,
Greg

Reply all
Reply to author
Forward
Message has been deleted
0 new messages