freeleaps-ops/first-class-pipeline/src/com/freeleaps/devops/SourceFetcher.groovy

25 lines
725 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.workspace = "${steps.env.WORKSPACE}/devops-workspace/${configurations.serviceName}"
steps.dir(steps.env.workspace) {
steps.git branch: configurations.serviceGitBranch, credentialsId: 'git-bot-credentials', url: configurations.serviceGitRepo
}
}
}