jenkinsci / jenkinsci/git-parameter-plugin

[JENKINS-61158] SharedLibrary usage doesn´t allow to fetch branches in git parameter

Open
#287 2 comments 0 reactions 0 assignees View on GitHub
component:git-parameter-plugin imported-jira-issue pipeline priority:critical resolution:unresolved
Dominant language
Java
Stars
131
Forks
134
Avg merge
21h 5m
Merged PRs (30d)
1

Description

Hello, 

 

I have the following pipeline that uses a method called "getServiceVersion" from a Shared Library.

 

#!/usr/bin/env groovy

@​Library('mycom')

import com.mycom.*

// Declarative pipeline //

properties([[$class: 'JiraProjectProperty'], buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')), disableConcurrentBuilds(), parameters([gitParameter(branch: '', branchFilter: '.*', defaultValue: 'origin/integration', description: 'Git Branch', listSize: '10', name: 'branch', quickFilterEnabled: true, selectedValue: 'DEFAULT', sortMode: 'ASCENDING_SMART', tagFilter: '*', type: 'PT_BRANCH')])])

def STAGE

pipeline {
    agent { label 'WindowsSlaveWS2016' }

    options {
        timestamps ()
        ansiColor('xterm')
        disableConcurrentBuilds()
    }

    stages {
        stage('Code checkout') {
            steps {
                echo '<< Checking out source code >>'
                checkout([$class: 'GitSCM', branches: [[name: '${branch}']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 10, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'gitcredentials', url: 'http://gitserver:8080/myproject']]])
                script {
                    STAGE=env.STAGE_NAME
                }
            }
        }
        stage('Get service version') {
            steps {
                script {
                    STAGE=env.STAGE_NAME
                    getServiceVersion('MY/Path''ChangeLog.txt''myservice')
                }
            }
        }

    }

}


Please notice at the 'git parameter (https://plugins.jenkins.io/git-parameter/)' that fetchs all available branches on the current repository and the selected default vale 'origin/integration'. 

 

Since I am using shared library it doesn´t load all the available branches and in fact it only displays origin/master instead of origin/integration.

 

There is a kind of incompatibility? How can I fix this behaviour?

 

 

---
Originally reported by joudaon, imported from: SharedLibrary usage doesn´t allow to fetch branches in git parameter


  • status: Open
  • priority: Critical
  • component(s): git-parameter-plugin
  • label(s): pipeline, plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 3
  • imported: 20251216-182730

Raw content of original issue

Hello, 
 
I have the following pipeline that uses a method called "getServiceVersion" from a Shared Library.
 



#!/usr/bin/env groovy

@Library('mycom')

import com.mycom.*

// Declarative pipeline //

properties([[$class: 'JiraProjectProperty'], buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')), disableConcurrentBuilds(), parameters([gitParameter(branch: '', branchFilter: '.*', defaultValue: 'origin/integration', description: 'Git Branch', listSize: '10', name: 'branch', quickFilterEnabled: true, selectedValue: 'DEFAULT', sortMode: 'ASCENDING_SMART', tagFilter: '*', type: 'PT_BRANCH')])])

def STAGE

pipeline {
    agent { label 'WindowsSlaveWS2016' }

    options {
        timestamps ()
        ansiColor('xterm')
        disableConcurrentBuilds()
    }

    stages {
        stage('Code checkout') {
            steps {
                echo '<< Checking out source code >>'
                checkout([$class: 'GitSCM', branches: [[name: '${branch}']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 10, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'gitcredentials', url: 'http://gitserver:8080/myproject']]])
                script {
                    STAGE=env.STAGE_NAME
                }
            }
        }
        stage('Get service version') {
            steps {
                script {
                    STAGE=env.STAGE_NAME
                    getServiceVersion('MY/Path''ChangeLog.txt''myservice')
                }
            }
        }

    }

}



Please notice at the 'git parameter (https://plugins.jenkins.io/git-parameter/)' that fetchs all available branches on the current repository and the selected default vale 'origin/integration'. 
 
Since I am using shared library it doesn´t load all the available branches and in fact it only displays origin/master instead of origin/integration.
 

There is a kind of incompatibility? How can I fix this behaviour?
 
 

1 attachment

- [shared_lib_error.jpg](https://issues.jenkins.io/secure/attachment/50354/shared_lib_error.jpg)
> ![shared_lib_error.jpg](https://issues.jenkins.io/secure/attachment/50354/shared_lib_error.jpg)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.