Child pages
  • Git Parameter Plugin
Skip to end of metadata
Go to start of metadata

Plugin Information

View Git Parameter on the plugin site for more information.

This plugin allows you to choose between Git tags or sha1 of your SCM repository so Git Plugin installed is required.

Plugin Info

This plugin allows you to assign git tag or revision number as parameter in Parametrized builds.
There is no need to set up anything special, this plugin will read your default configuration from Git Plugin.

It firstly fetching (by git fetch) current repository, and listing all the tags/sha1's to choose from.

You can select the following sorting options for tags/revision/branches/branches_or_tags

  • none
  • descending
  • ascending
  • ascending smart
  • descending smart

For the smart variants the compare treats a sequence of digits as a single character. Contributed by Graeme Hill.

Releases schedule

?

Changelog

16/04/2018 Version 0.9.2

  • JENKINS-50776: Default selected item doesn’t always honor exactly Default Value
  • JENKINS-49727: Add optional parameter to specify the number of items the list will display 

18/02/2018 Version 0.9.1

  • JENKINS-45419'Use Repository' setting does not find other remote urls if multiple repos are added to job
  • PR #55: Add complete French support

02/11/2017 Version 0.9.0

  • JENKINS-47110: Retrieving Git references do not work with variable in Repository URL
  • PR #54: Help improvement: complete English translation, and reorder items
  • JENKINS-47078: IndexOutOfBoundsException for pipeline job
  • JENKINS-39530Add support to Pipeline projects

04/09/2017 Version 0.8.1

  • JENKINS-46216: Null Pointer exception when no default parameter provided
  • JENKINS-45577: [Git Parameter Plugin] Parameter does not support the definition from CLI
  • JENKINS-46624: fix remote name
  • JENKINS-46185: Set browser focus to filter after the QuickFilter has been filled
  • JENKINS-46038Extend list of supported type with pull request
  • JENKINS-26799: Multiple SCMs plugin support part 3 (Work fine when selected revisions)
  • JENKINS-42313Default Value not honoured

02/06/2017 Version 0.8.0

23/01/2017 Version 0.7.2

  • JENKINS-41091: git-parameter:0.7.1 breaks the multi-line parameters in rebuild

11/27/2016 Version 0.7.1

09/12/2016 Version 0.7.0

08/06/2016 Version 0.6.2

  • JENKINS-36833: Race Condition Populating Multiple Tag Parameters
  • JENKINS-36934: No return value passed to the url
  • JENKINS-31939: The top value is better to be chosen by default of to have such option (part 3)

07/19/2016 Version 0.6.1

  • JENKINS-31939: The top value is better to be chosen by default of to have such option (part 2)

07/06/2016 Version 0.6.0

  • JENKINS-36104: Add Repo SCM support (Derron Hu)
  • JENKINS-16290: git parameter plugin doesn't support Jenkins slave setup with git repos checked out only on slaves
  • JENKINS-35363: Git parameter filter doesn't work

05/03/2016 Version 0.5.1

04/02/2016 Version 0.5.0

1. User interface

  • JENKINS-27435: Quick branch filter (Thank Bruno P. Kinoshita for inspiration)
  • JENKINS-33963: Branch filter does not save the value (part of the work Joe Hansche)

2. Refactor/fix/feature

  • JENKINS-33361: Long release number in branch, tag or revision name
  • JENKINS-33084: Git Parameter plugin should prune stale remote branches (@darashenka)
  • JENKINS-31939: The top value is better to be chosed by default of to have such option
  • JENKINS-33831: Revision Parameter Type: ArrayIndexOutOfBoundsException
  • JENKINS-33912: Refactoring Test Case

01/16/2015 Version 0.4.0

  • Possibility to select branch, tag or branch (Alban Dericbourg)
  • Keep complex logics in jelly as less as possible (Yestin Sun)
  • support folders (Nicolas De Loof)
  • Minimized pom.xml as suggested by Jesse Glick
  • Removed LICENSE.txt as suggested by Jesse Glick

05/14/14 Version 0.3.2

User visible changes are:

  • Updated help texts for configuration and when selecting your tag/revision
  • Runs a fetch each time the user enters the "Build with parameter".
  • Run clone when fetch fails on workspace empty (Gabor Liptak)
  • Merging SortMode from graeme-hill
  • With an empty workspace the tags are calculated after we made a checkout. This may take a long time.

Changes relevant to developer

  • Added MIT-LICENSE.txt to use the same license as Jenkins-CI.
  • Added Contributors.textile
  • Display month not minutes in date. Add HH.mm. Display only first 8 chars of SHA1 (Niklaus Giger)
  • Add backup pluginRepository (Gabor Liptak)
  • Use GitTool to query configured location of the git executable (gliptak)
  • Upgrade to git 2.2.0. (christ66)
  • Build against latest stable Jenkins-CI version 1.554.1
  • New co-maintainer/developer Niklaus Giger (id ngiger)
  • Version 0.3 and 0.3.1 never made it to the distribution, because of problems with the release mechanism.

02/21/12 Version 0.2

  • Corrected error - plugin wasn't showing anything after change of main Git Plugin
  • Corrected major dis-functionality - plugin now it showing revisions only from correct job/project.
  • Adding support for choosing branch from which revisions/tags are returned

11/01/11 Version 0.1

  • Initial Release

24 Comments

  1. Hi !

    Thanks to provide this feature ! I need it for a few monthes (smile)

    Some concerns I have with the actual version of the plugin :

    • It would be great to lower the minimum jenkins version required to use the plugin (at least, going to the latest LTS 1.424). It's nothing than changing the parent pom version in your plugin artefact (and it would allow more people including me (wink) to use your plugin)
    • When I created a new job using the git parameter, the first time I launched the plugin, list was empty. Is it normal ? How do you retrieve tag lists (do you retrieve remote tags ? or local tags ?)
    • I would love to have a new parameter type : "every existing refs" (ie "every tags or branches in the git repo"). Typically, when I want to deploy my app, I want to either deploy a tag or a branch HEAD (wink)

    Thanks for the work though (smile)

  2. Hi,

    I can't make this plugin to read new tag from original repository, what I'm getting is list of tags or SHA-1 hashes from previously cloned repository in Jenkis workspace.

    This is pretty useless because most often I need to choose most recent tag before cloning that repository to the workspace to be able to process this most recent in build steps.

    Could you please tell me how to get list of current tags from the original repository not old workspace clone?

    Besides it somehow cashes the results and after adding new tags I need to go to job configuration to switch from tag to revision, make a build, then switch backwards from revision to tag get tag list up to date (I tried that on two different Jenkins instances on different servers)

    1. Unknown User (vladiksip@centrum.cz)

      Hi Pawel,

      I've got the same problem as you... could you please tell me how did you solved it?

      Thanks in advance,

      -Vlada

      1. Hi Vlada,

        I'm using git post receive hook, this is a script which git runs after push:

        tags=`ls /var/git/data.gov.uk.git/refs/tags | sed -n '/.rc/!p' | tr '\n' ','`
        echo "TAGS=$tags" > /home/dgu/dgu_git_tags
        branches=`git --git-dir /var/git/data.gov.uk.git/ branch | tr -d '*' | tr -d ' ' | tr '\n' ','`
        echo "BRANCHES=$branches" > /home/dgu/dgu_git_branches

        It creates two files: dgu_git_tags and dgu_git_branches.

        These files are used by Extended Choice Parameter plugin with following configuration:

        Name: TAG

        Property File: /home/dgu/dgu_git_tags

        Property Key: TAGS

        I hope it helps.

        Pawel

        1. Thanx for that great comment! it was very helpful!

        2. For anyone interested, I followed Pawel's lead and took it further so that you don't need to add hooks or scripts.  Pure Jenkins all the way with a tags and branches list that is always up to date.

          I describe how to do it in my blog post here:

          Jenkins and Git at Plaid Speed

          It uses the Extensible Choice Parameter plugin to launch an inline Groovy script to fetch current tag and branch data directly from a remote Git repo.

  3. Hi, 

    Has anyone managed to get this working? When I specify a git parameter and build, the page doesn't respond and hangs. 

    Thanks

  4. How do you indicate the repository?  I'm seeking to use this as a replacement for the List Subversion Tags parameter as we migrate from SVN to Git.

    Thanks,

    Dan

    1. I've added the use of this, asking for a pulldown of tags for a project that has been cloned and fetched, and that has 6 tags, and when the parameter choices are displayed the following is spewed to the logs:

      Caused by: hudson.plugins.git.GitException: Command "git.exe fetch -t" returned status code 128:
      stdout:
      stderr: fatal: Not a git repository (or any of the parent directories): .git

              at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:897)
              at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:858)
              at hudson.plugins.git.GitAPI.fetch(GitAPI.java:200)
              at hudson.plugins.git.GitAPI.fetch(GitAPI.java:204)
              at net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition.generateContents(GitParameterDefinition.java:236)
              at net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition.getTagMap(GitParameterDefinition.java:299)
              ... 159 more

      I cannot figure out what the issue is.  It is as if it isn't able to determine that I have a git workspace.

  5. How does this plugin set the git directory?  Currently I see in the log that it is using D:\Jenkins but that directory doesn't exist and it is not the value of the JENKINS_HOME variable

    Thank you,

  6. I think this is the right plugin that I'm looking for but I'm not sure how to configure it correctly to accomplish what I want. I'm trying to configure a Jenkins project to build ONLY if my git commit contains a specific tag named (demo). Could anyone assist me on configure this correctly? Thank you in advanced!

  7. Hi all,

    how to set the default value - the most top value from the list?

  8. Unknown User (ckutz)

    Has anyone figured out what the 'branch' and 'tag filter' options are working?
    I would like to list only all 'release/*' branches, but neither branch nor tag filter doesn't seem to have any effect!?

  9. Its fixed by Boguslaw Klimas and was supposed to release by 04/02/16. Any updates on this ?? when will it be released?

  10. It would be really useful if this plugin will allow us to specify the repository source for getting the branches or releases as these are usually not the ones from the same repository where we keep our build scripts.

  11. How do I have Jenkins checkout the selected revision? I was able to get the branch option working by naming the parameter named Branch, then for the jobs Branches To Build setting, I just referenced the environmental variable Branch.

    But I don't see where I can do that for the revision?

    Thanks

  12. Can anybody please help me with plugin configuration for multiple repository project?

    I have following issue using plugin.

    I have an Ansible deployment scenario managed by Jenkins. All Ansible scripts are located in repository https://<some host>/sops.git

    Ansible scripts deploy a war to application server. Source code for war file is located in repository https://<some host>/platform.git.

    To deploy necessary war file I need to enter GIT revision that is included into war build number.

    I'm trying to use Git parameter plugin.

    1. I added both repositories into jenkins job SCM list (first repository is https://<some host>/sops.git, second is https://<some host>/platform.git)
    2. I added parameter war_revision in the list of build parameters as a GIT parameter with type revision. To specify repository I entered full repository path to "Use repository" field
    3. When Im trying to start parameterized build - message "No GIT repository configured in SCM configuration" is shown in parameter value select field
    4. If I clean  "Use repository" field parameter field in a start build form is populated with repository https://<some host>/sops.git revisions - and that is not what i need 

    What do I need to do to get things done and have my repository https://<some host>/platform.git revisions list in parameter field?

    I'm using plugin version 0.8.0 with Jenkins 1.652

    KR, Sergey

    1. You'll get far better results from asking that type of question on the Jenkins users mailing list, rather than as a question on a wiki page.

  13. I've problem to set a Tag Filter.

    I need to get last tag of origin/master branch 

    On plugin i've insered this value:

    --points-at origin/master

    The complete git instruction should be:

    git tag -l --points-at origin/master

    This command on terminal works correctly, but on plugin i don't see nothing

    Do you have any Idea?

    Note:

    git version 2.11.0

     

  14. Could someone provide me with an example of how to use this plugin within a Jenkinsfile please. 

  15. Me too please, I cannot find any documentation on it anywhere

  16. backgound information:

    1. we have two branch with the similar name: origin/master, origin/master-2015
    2. We tried to set the default value to origin/master, however, the selection pick up origin/master-2015 instead
    3. we are trying to use negative lookahead to filter out the origin/master-2015 branch, but the list is populated with letters and numbers like "A" "B" "C"...
    4. The regex that I am using in the filter is ^((?!master-2015).)*$

    so, 

    1. is the issue addressed in the point 2 a known issue?
    2. Does negative lookahead regex works for this plugin?
  17. Issue 2 should be fixed by  JENKINS-50776 - Getting issue details... STATUS .

Write a comment…