mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
36837ad3b8
In case there is an error in another pipeline step inside a foreign pipeline we got nevertheless an error explaining there is an issue inside the pipeline load step.
47 lines
1.6 KiB
Groovy
47 lines
1.6 KiB
Groovy
import com.sap.piper.Utils
|
|
|
|
/**
|
|
* pipelineExecute
|
|
* Load and executes a pipeline from another git repository.
|
|
*
|
|
*/
|
|
def call(Map parameters = [:]) {
|
|
|
|
node() {
|
|
|
|
def path
|
|
|
|
handlePipelineStepErrors (stepName: 'pipelineExecute', stepParameters: parameters) {
|
|
|
|
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', '')
|
|
|
|
deleteDir()
|
|
|
|
checkout([$class: 'GitSCM', branches: [[name: branch]],
|
|
doGenerateSubmoduleConfigurations: false,
|
|
extensions: [[$class: 'SparseCheckoutPaths',
|
|
sparseCheckoutPaths: [[path: path]]
|
|
]],
|
|
submoduleCfg: [],
|
|
userRemoteConfigs: [[credentialsId: credentialsId,
|
|
url: repo
|
|
]]
|
|
])
|
|
|
|
}
|
|
load path
|
|
}
|
|
}
|