freeleaps-ops/first-class-pipeline/src/com/freeleaps/devops/SourceFetcher.groovy
2025-02-07 15:44:52 +08:00

25 lines
740 B
Groovy

package com.freeleaps.devops
class SourceFetcher {
def steps
SourceFetcher(steps) {
this.steps = steps
}
def fetch(configurations) {
if (configurations.serviceGitRepo == null || configurations.serviceGitRepo.isEmpty()) {
steps.error("serviceGitRepo is required")
}
if (configurations.serviceGitBranch == null || configurations.serviceGitBranch.isEmpty()) {
steps.error("serviceGitBranch is required")
}
steps.env.workroot = "${steps.env.WORKSPACE}/devops-workspace/${configurations.serviceName}"
steps.dir(steps.env.workroot) {
steps.git branch: configurations.serviceGitBranch, credentialsId: configurations.serviceGitCredentialsId, url: configurations.serviceGitRepo
}
}
}