This plugin is really good. But currently it doesn't support "Multiple SCMs plugin". If I configure the job with multiple Git repos it wont detect branches.

      This would be a very good feature.

        1. git parameter.jpg
          git parameter.jpg
          12 kB
        2. screenshot-4.png
          screenshot-4.png
          24 kB
        3. screenshot-3.png
          screenshot-3.png
          22 kB
        4. screenshot-2.png
          screenshot-2.png
          23 kB
        5. screenshot-1.png
          screenshot-1.png
          12 kB

          [JENKINS-26799] Multiple SCMs plugin support

          Dirk Hain added a comment -

          I can confirm the same issue. This plugin would be great but I cannot use it because I need to fetch 2 git repositories.

          Dirk Hain added a comment - I can confirm the same issue. This plugin would be great but I cannot use it because I need to fetch 2 git repositories.

          Nikolas Falco added a comment -

          I confirm the same needs. We often must download more than git repositories (as the SVN plugin), because we do not use git submodules.

          Nikolas Falco added a comment - I confirm the same needs. We often must download more than git repositories (as the SVN plugin), because we do not use git submodules.

          Yes, this would be a good feature! I need to query tags from a specific repo (via Git Parameter Plugin) and tag each of them in the post-build phase.

          Rosberg Linhares added a comment - Yes, this would be a good feature! I need to query tags from a specific repo (via Git Parameter Plugin) and tag each of them in the post-build phase.

          Alex Lance added a comment -

          This would be an outstanding addition for a CI workflow.

          We're trying to build a pipeline that permits developers to deploy their feature branches before they are merged into master.

          Often there are projects that have many git repos in them. Being able to dynamically select the branch for each repo at build
          time would be extremely useful.

          Alex Lance added a comment - This would be an outstanding addition for a CI workflow. We're trying to build a pipeline that permits developers to deploy their feature branches before they are merged into master. Often there are projects that have many git repos in them. Being able to dynamically select the branch for each repo at build time would be extremely useful.

          Dakota Brown added a comment -

          klimas7,

          It looks like this would be a matter of modifying GitParameterDefinition.getProjectSCM() with another option like the RepoSCM

          The class of the multiSCM plugin is org.jenkinsci.plugins.multiplescms.MultiSCM

          and the method that returns a list of SCMs is for MultiSCM getConfiguredSCMs() which returns a list of SCMs.

          If I can find some time in the next few weeks, I'll try to help out with this

          Dakota Brown added a comment - klimas7 , It looks like this would be a matter of modifying GitParameterDefinition.getProjectSCM() with another option like the RepoSCM The class of the multiSCM plugin is org.jenkinsci.plugins.multiplescms.MultiSCM and the method that returns a list of SCMs is for MultiSCM getConfiguredSCMs() which returns a list of SCMs. If I can find some time in the next few weeks, I'll try to help out with this

          Nikolas Falco added a comment -

          Would be great

          Nikolas Falco added a comment - Would be great

          Boguslaw Klimas added a comment - - edited

          Hi luckless
          This solution perhaps is ok, but the method getConfiguredSCMs() which returns a list of SCMs.
          Which SCMs of list I should choose to present in parameters? All/first/add combo to chose scm?
          Currently I don't have a good idea to resolve this problem.

          Regards
          Boguslaw

          Boguslaw Klimas added a comment - - edited Hi luckless This solution perhaps is ok, but the method getConfiguredSCMs() which returns a list of SCMs. Which SCMs of list I should choose to present in parameters? All/first/add combo to chose scm? Currently I don't have a good idea to resolve this problem. Regards Boguslaw

          Nikolas Falco added a comment -

          I think a solution could be a combo that show a sorted list (so it groups by SCM)

          • SCM Unique Name/TAG1
          • SCM Unique Name/TAG2
          • SCM Unique Name2/BRANCHA
          • SCM Unique Name2/BRANCHB

          Nikolas Falco added a comment - I think a solution could be a combo that show a sorted list (so it groups by SCM) SCM Unique Name/TAG1 SCM Unique Name/TAG2 SCM Unique Name2/BRANCHA SCM Unique Name2/BRANCHB

          Dakota Brown added a comment -

          klimas7,

          That is where my solution stops being a good one I've been thinking about it but haven't come up with a solution besides choosing the first GitSCM in the list.

          For my purposes that would be enough but it isn't universal

          nfalco,

          The problem with that solution is that the mutli scm plugin doesn't require unique scm names so long as the subdirectory they check out to is different.

          Dakota Brown added a comment - klimas7 , That is where my solution stops being a good one I've been thinking about it but haven't come up with a solution besides choosing the first GitSCM in the list. For my purposes that would be enough but it isn't universal nfalco , The problem with that solution is that the mutli scm plugin doesn't require unique scm names so long as the subdirectory they check out to is different.

          Nikolas Falco added a comment - - edited

          I've debug a little bit and checked actual our jobs.

          About unique name:
          The unique scm name in a GIT SCM is not required but suggested (as described in the help of additional behaviour "Custom SCM Name"). The method getScmName() to retrieve that name was deprecated and could get null if not defined. Documentation say to use GitSCM.getKey() that always give to you a valid unique name for that git scm repository.

          About parameter:
          Some our jobs has more than 15 git repository to download before run the build script taken from an SVN repo :\
          Actually we have a String Parameter like REPOX_BRANCH for each repository. No sense have only git parameter for all repositories.
          I think a good solution was add to actual git parameter definition a combo with the list of all GitSCM.getKey() returned by MultiSCM (optional dependency).
          Instead when you execute a new build in getProjectSCM() method in case of MultiSCM it should iterate over getConfiguredSCMs() and return that one matches the key choosed in job configuration.

          Nikolas Falco added a comment - - edited I've debug a little bit and checked actual our jobs. About unique name: The unique scm name in a GIT SCM is not required but suggested (as described in the help of additional behaviour "Custom SCM Name"). The method getScmName() to retrieve that name was deprecated and could get null if not defined. Documentation say to use GitSCM.getKey() that always give to you a valid unique name for that git scm repository. About parameter: Some our jobs has more than 15 git repository to download before run the build script taken from an SVN repo :\ Actually we have a String Parameter like REPOX_BRANCH for each repository. No sense have only git parameter for all repositories. I think a good solution was add to actual git parameter definition a combo with the list of all GitSCM.getKey() returned by MultiSCM (optional dependency). Instead when you execute a new build in getProjectSCM() method in case of MultiSCM it should iterate over getConfiguredSCMs() and return that one matches the key choosed in job configuration.

          Dakota Brown added a comment -

          I think that's part of the difficulty though since that getProjectSCM() method has a return type for a singular SCM object.

          At that point, it affects a lot more than just multi-scm plugin. making that return a list of GitSCM objects turns into a high-impact change

          Dakota Brown added a comment - I think that's part of the difficulty though since that getProjectSCM() method has a return type for a singular SCM object. At that point, it affects a lot more than just multi-scm plugin. making that return a list of GitSCM objects turns into a high-impact change

          Nikolas Falco added a comment -

          No because in the method getProjectSCM() you have to match the selected scmKey you have configured in the job with the ConfiguredSCM()

          Nikolas Falco added a comment - No because in the method getProjectSCM() you have to match the selected scmKey you have configured in the job with the ConfiguredSCM()

          Nikolas Falco added a comment -

          This is only a working POC (proof of concept)
          https://github.com/nfalco79/git-parameter-plugin/tree/feature/JENKINS-26799

          It works but:

          • here MultiSCM is not an real optional dependency (I do not know if jenkins have some API to avoid Class.forName("") to know if a plugin is installed)
          • missing test case
          • missing handle event when you change repo URL and you have not set an SCM name (why if you not set any SCM Name the SCM key it's the string "git " + repoURL)
          • maybe some faultback for backward compatibility

          Nikolas Falco added a comment - This is only a working POC (proof of concept) https://github.com/nfalco79/git-parameter-plugin/tree/feature/JENKINS-26799 It works but : here MultiSCM is not an real optional dependency (I do not know if jenkins have some API to avoid Class.forName("") to know if a plugin is installed) missing test case missing handle event when you change repo URL and you have not set an SCM name (why if you not set any SCM Name the SCM key it's the string "git " + repoURL) maybe some faultback for backward compatibility

          Dakota Brown added a comment -

          I like the general direction. I'll look closely at it when I get the chance

          Dakota Brown added a comment - I like the general direction. I'll look closely at it when I get the chance

          Boguslaw Klimas added a comment - - edited

          nfalco79 This is very good POC but

          You may not have defined SCM when you add parameter or SCM definition can change after add parameter. Then you not have the actual information about SCM in parameter definition.

          I think good and simple solution is a:
          Add two option:

          • MultipleSCM: FIRST, ALL, MATCH_REPOSITORY_URL (combo)
          • MultipleSCM Url: ______ (text field - regexp)

          'FIRST' is default value.
          If you choose 'FIRST' - plugin will take data from first defined SCM (git repository)
          'ALL' plugin take data from all defined SCM
          'MATCH_REPOSITORY_URL' plugin will take data from all SCM which url match from regular expression.

          The advantage of this solution is: you do not need know about defined SCM. and this and this is more flexible solution.

          Perhaps is enough option 'MATCH_REPOSITORY_URL' and adding one text field to configuratin.

          Regards
          Boguslaw

          Boguslaw Klimas added a comment - - edited nfalco79 This is very good POC but You may not have defined SCM when you add parameter or SCM definition can change after add parameter. Then you not have the actual information about SCM in parameter definition. I think good and simple solution is a: Add two option: MultipleSCM: FIRST, ALL, MATCH_REPOSITORY_URL (combo) MultipleSCM Url: ______ (text field - regexp) 'FIRST' is default value. If you choose 'FIRST' - plugin will take data from first defined SCM (git repository) 'ALL' plugin take data from all defined SCM 'MATCH_REPOSITORY_URL' plugin will take data from all SCM which url match from regular expression. The advantage of this solution is: you do not need know about defined SCM. and this and this is more flexible solution. Perhaps is enough option 'MATCH_REPOSITORY_URL' and adding one text field to configuratin. Regards Boguslaw

          Nikolas Falco added a comment -

          klimas7 I have some doubts about FIRST and ALL value option.

          • FIRST not work if no SCM defined and maybe I would have the commit or TAG value to do some kinds of work based on parameter value without source code (for example download binary deployed on artifactory with release tag).
          • ALL could be a very confusing if BRANCH or REVISION are selected and more than one SCM is defined
            So the really useful choise is MATCH_REPOSITRY_URL but also in this case you could not use it when no SCM is defined.

          The SVN strategy is very simple and usable

          You always put the complete git URL and you could also select credential stored in jenkins so more issue JENKINS-28597

          Nikolas Falco added a comment - klimas7 I have some doubts about FIRST and ALL value option. FIRST not work if no SCM defined and maybe I would have the commit or TAG value to do some kinds of work based on parameter value without source code (for example download binary deployed on artifactory with release tag). ALL could be a very confusing if BRANCH or REVISION are selected and more than one SCM is defined So the really useful choise is MATCH_REPOSITRY_URL but also in this case you could not use it when no SCM is defined. The SVN strategy is very simple and usable You always put the complete git URL and you could also select credential stored in jenkins so more issue JENKINS-28597

          Boguslaw Klimas added a comment - - edited

          Hi nfalco
          The solution to this issue is only part of a larger issue JENKINS-39530.
          Finally I will add only one new option in configuration 'Use repository', this option will be a regular expression. It will be taken into account only, when is defined more then one SCM in job.
          When properties is empty plugin get first SMC from job.

          From my perspective, any change must be transparent for current user.
          Regards
          Bogusław

          Boguslaw Klimas added a comment - - edited Hi nfalco The solution to this issue is only part of a larger issue JENKINS-39530 . Finally I will add only one new option in configuration 'Use repository', this option will be a regular expression. It will be taken into account only, when is defined more then one SCM in job. When properties is empty plugin get first SMC from job. From my perspective, any change must be transparent for current user. Regards Bogusław

          Boguslaw Klimas added a comment - https://github.com/jenkinsci/git-parameter-plugin/pull/41

          Release 0.7.1

          Boguslaw Klimas added a comment - Release 0.7.1

          Oleksii Shevchenko added a comment - - edited

          Apparently does not work when your second SCM cloned to subdir (GIT).

          Oleksii Shevchenko added a comment - - edited Apparently does not work when your second SCM cloned to subdir (GIT).

          Hi felikz
          I reopen this isssue and i will try to fix this

          Boguslaw Klimas added a comment - Hi felikz I reopen this isssue and i will try to fix this

          klimas7 Thanks. So I have 2 git repositories. First is cloned at root of workspace, second to subdir of first repo. Having this setup I am not able to Regexp second repo, only first matching.

          Oleksii Shevchenko added a comment - klimas7 Thanks. So I have 2 git repositories. First is cloned at root of workspace, second to subdir of first repo. Having this setup I am not able to Regexp second repo, only first matching.

          Code changed in jenkins
          User: Boguslaw Klimas
          Path:
          src/test/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinitionTest.java
          http://jenkins-ci.org/commit/git-parameter-plugin/6336b41960434597180ab883b81d8e26e03b3641
          Log:
          Merge pull request #45 from jenkinsci/feature/JENKINS-26799

          Multiple SCMs plugin support

          Compare: https://github.com/jenkinsci/git-parameter-plugin/compare/570bf0fbb7b0...6336b4196043

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Boguslaw Klimas Path: src/test/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinitionTest.java http://jenkins-ci.org/commit/git-parameter-plugin/6336b41960434597180ab883b81d8e26e03b3641 Log: Merge pull request #45 from jenkinsci/feature/ JENKINS-26799 Multiple SCMs plugin support Compare: https://github.com/jenkinsci/git-parameter-plugin/compare/570bf0fbb7b0...6336b4196043

          release 0.8.1

          Boguslaw Klimas added a comment - release 0.8.1

            klimas7 Boguslaw Klimas
            xfreebird Nicolae Ghimbovschi
            Votes:
            7 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: