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

6 views
Skip to first unread message

jonuda77@gmail.com (JIRA)

unread,
Feb 20, 2020, 3:13:05 AM2/20/20
to jenkinsc...@googlegroups.com
Jon Udaondo updated an issue
 
Jenkins / Bug JENKINS-61158
SharedLibrary usage doesn´t allow to fetch branches in git parameter
Change By: Jon Udaondo
Hello, 
 
I have the following pipeline that uses a method called "getServiceVersion" from a Shared Library.
 
{code:java}
#!/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')
                }
            }
        }

    }

}{code}
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?
 
!shared_lib_error.jpg!
 
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

jonuda77@gmail.com (JIRA)

unread,
Feb 20, 2020, 3:13:05 AM2/20/20
to jenkinsc...@googlegroups.com
Jon Udaondo created an issue
Issue Type: Bug Bug
Assignee: Boguslaw Klimas
Components: git-parameter-plugin
Created: 2020-02-20 08:12
Labels: plugin pipeline
Priority: Critical Critical
Reporter: Jon Udaondo

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?
 


 

jonuda77@gmail.com (JIRA)

unread,
Feb 20, 2020, 3:14:02 AM2/20/20
to jenkinsc...@googlegroups.com

jonuda77@gmail.com (JIRA)

unread,
Feb 20, 2020, 3:14:03 AM2/20/20
to jenkinsc...@googlegroups.com
Jon Udaondo updated an issue
Hello, 
 
I have the following pipeline that uses a method called "getServiceVersion" from a Shared Library.
 
{code:java}

#!/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')
                }
            }
        }

    }

}{code}
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.
 

!shared_lib_error.jpg!


There is a kind of incompatibility? How can I fix this behaviour?
 
 
Reply all
Reply to author
Forward
0 new messages