3

In jenkins job, is it possible to have multiple git repositories and dynamically selecting the repository on the basis of parameter ?

sup570
  • 53
  • 6

1 Answers1

0

You can set the git URL in a jenkins pipeline, as in here:

pipeline {
    agent any


    parameters { 
        string(defaultValue: "https://github.com", description: 'Whats the github URL?', name: 'URL')
    }


    stages {
        stage('Checkout Git repository') {
           steps {
                git branch: 'master', url: "${params.URL}"
            }
        }

        stage('echo') {
           steps {
                echo "${params.URL}"
            }
        }
    }
}

That is using the git step (illustrated here)

You can also set it depending on a sub-folder, if you needed to checkout multiple Git repositories.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250