in vars/CodeReview.groovy [27:98]
def call() {
def context = [:]
node("master") {
updateGitlabCommitStatus name: 'Jenkins', state: 'running'
stage("Init") {
context.platform = new PlatformFactory().getPlatformImpl(this)
context.job = new Job(JobType.CODEREVIEW.value, context.platform, this)
context.job.init()
println("[JENKINS][DEBUG] Created object job with type - ${context.job.type}")
context.git = new GitInfo(context.job, context.platform, this)
context.git.init()
context.nexus = new Nexus(context.job, context.platform, this)
context.nexus.init()
context.sonar = new Sonar(context.job, context.platform, this)
context.sonar.init()
context.codebase = new Codebase(context.job, context.git.project, context.platform, this)
context.codebase.setConfig(context.git.autouser, context.git.host, context.git.sshPort, context.git.project, context.git.repositoryRelativePath)
context.factory = new StageFactory(script: this)
context.factory.loadEdpStages().each() { context.factory.add(it) }
context.factory.loadCustomStagesFromLib().each() { context.factory.add(it) }
context.factory.loadCustomStages("${WORKSPACE.replaceAll("@.*", "")}@script/stages").each() {
context.factory.add(it)
}
context.job.printDebugInfo(context)
println("[JENKINS][DEBUG] Codebase config - ${context.codebase.config}")
context.job.setDisplayName("${currentBuild.number}-${context.git.displayBranch}(${context.git.changeName})")
context.job.setDescription("Name: ${context.codebase.config.name}\r\nLanguage: ${context.codebase.config.language}" +
"\r\nBuild tool: ${context.codebase.config.build_tool}\r\nFramework: ${context.codebase.config.framework}", true)
}
}
node(context.codebase.config.jenkinsSlave.toLowerCase()) {
context.workDir = new File("/tmp/${RandomStringUtils.random(10, true, true)}")
context.workDir.deleteDir()
context.buildTool = new BuildToolFactory().getBuildToolImpl(context.codebase.config.build_tool, this, context.nexus, context.job)
context.buildTool.init()
context.job.stages.each() { stage ->
if (stage instanceof ArrayList) {
def parallelStages = [:]
stage.each() { parallelStage ->
parallelStages["${parallelStage.name}"] = {
try {
context.job.runStage(parallelStage.name, context)
}
catch (Exception ex) {
context.job.failStage(parallelStage.name, ex)
}
}
}
parallel parallelStages
} else {
try {
context.job.runStage(stage.name, context)
}
catch (Exception ex) {
context.job.failStage(stage.name, ex)
}
}
}
}
updateGitlabCommitStatus name: 'Jenkins', state: "success"
}