2017-11-24 13:33:26 +02:00
|
|
|
import com.sap.piper.Utils
|
|
|
|
|
|
|
|
/**
|
2017-12-01 11:51:11 +02:00
|
|
|
* pipelineExecute
|
2017-11-29 13:26:47 +02:00
|
|
|
* Load and executes a pipeline from another git repository.
|
2017-11-24 13:33:26 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
def call(Map parameters = [:]) {
|
|
|
|
|
2017-12-01 18:00:30 +02:00
|
|
|
node() {
|
2017-11-24 13:33:26 +02:00
|
|
|
|
2017-12-01 18:00:30 +02:00
|
|
|
def path
|
2017-11-24 13:33:26 +02:00
|
|
|
|
2017-12-01 18:00:30 +02:00
|
|
|
handlePipelineStepErrors (stepName: 'pipelineExecute', stepParameters: parameters) {
|
2017-11-24 13:33:26 +02:00
|
|
|
|
2017-12-01 18:00:30 +02:00
|
|
|
def utils = new Utils()
|
|
|
|
|
|
|
|
// The coordinates of the pipeline script
|
|
|
|
def repo = utils.getMandatoryParameter(parameters, 'repoUrl', null)
|
|
|
|
def branch = utils.getMandatoryParameter(parameters, 'branch', 'master')
|
|
|
|
|
|
|
|
path = utils.getMandatoryParameter(parameters, 'path', 'Jenkinsfile')
|
|
|
|
|
|
|
|
// In case access to the repository containing the pipeline
|
|
|
|
// script is restricted the credentialsId of the credentials used for
|
|
|
|
// accessing the repository needs to be provided below. The corresponding
|
|
|
|
// credentials needs to be configured in Jenkins accordingly.
|
|
|
|
def credentialsId = utils.getMandatoryParameter(parameters, 'credentialsId', '')
|
2017-11-24 13:33:26 +02:00
|
|
|
|
2017-11-28 10:34:54 +02:00
|
|
|
deleteDir()
|
2017-11-24 13:33:26 +02:00
|
|
|
|
|
|
|
checkout([$class: 'GitSCM', branches: [[name: branch]],
|
|
|
|
doGenerateSubmoduleConfigurations: false,
|
|
|
|
extensions: [[$class: 'SparseCheckoutPaths',
|
|
|
|
sparseCheckoutPaths: [[path: path]]
|
|
|
|
]],
|
|
|
|
submoduleCfg: [],
|
|
|
|
userRemoteConfigs: [[credentialsId: credentialsId,
|
|
|
|
url: repo
|
|
|
|
]]
|
|
|
|
])
|
|
|
|
|
2017-11-28 10:34:54 +02:00
|
|
|
}
|
2017-12-01 18:00:30 +02:00
|
|
|
load path
|
2017-11-24 13:33:26 +02:00
|
|
|
}
|
|
|
|
}
|