#!/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')
}
}
}
}
}
If in the task are defined multiple repositories, this option specifies which the repository is taken into account on getting data.
If the option is not defined, is taken a first defined repository.
This option is a regular expression, which is compared to the 'Repository URL'.
You can define the multiple SCM for few way, you can use Multiple SCMs Plugin, specified many 'Repository URL' in one SCM or define them in pipeline.
Consider an example based on two repositories:
pipeline { agent any parameters { gitParameter branchFilter: 'origin.*/(.*)', defaultValue: 'master', name: 'BRANCH_A', type: 'PT_BRANCH', useRepository: '.*exampleA.git' gitParameter branchFilter: 'origin.*/(.*)', defaultValue: 'master', name: 'BRANCH_B', type: 'PT_BRANCH', useRepository: '.*exampleB.git' } stages { stage('Example') { steps { git branch: "${params.BRANCH_A}", url: 'https://github.com/klimas7/exampleA.git' git branch: "${params.BRANCH_B}", url: 'https://github.com/klimas7/exampleB.git' } } } }
Hope this solves the issue