Skip to content

Jenkins pipeline can't load the assigned git repository #24

Description

@hvsop

Hello everyone,

I am using jenkins version 2.303.3 and git parameter plugin version 0.9.14, and setup jenkins pipeline as below, then committed the pipeline code to "git@repository_b.git' :

###################

pipeline {

agent {
label "any"
}
environment {
gitUrl = 'git@repository_a.git'
}

parameters {
gitParameter name: 'branchName',
description: '',
type: 'PT_BRANCH_TAG',
defaultValue: 'origin/master',
branch: '',
branchFilter: '.',
tagFilter: '
',
sortMode: 'NONE',
selectedValue: 'NONE',
useRepository: env.gitUrl,
quickFilterEnabled: 'false',
listSize: '10'
}

    stage('Pull SCM'){
      steps {
        echo "Checkout codes"
        checkout([$class: 'GitSCM', branches: [[name: env.branchName]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "jenkins", url: env.gitUrl]]])
      }
    }

}

}

###################

After successfully built the jenkins job, I found the jenkins pipeline parameters "branchName" , was load branches from the jenkins pipeline repository (repository_b.git), instead of the correct one(git@repository_a.git), isn't the repository should be used from the env.gitUrl repository in the parameters section ?

Please help.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions