@@ -307,60 +307,67 @@ class MROPipelineUtil extends PipelineUtil {
307307 repo. id,
308308 {
309309 this . executeBlockAndFailBuild {
310- def baseDir = " ${ this.steps.env.WORKSPACE} /${ REPOS_BASE_DIR} /${ repo.id} "
310+ def currentBaseDir = " ${ this.steps.env.WORKSPACE} /${ REPOS_BASE_DIR} /${ repo.id} "
311311 def targetEnvToken = this . project. buildParams. targetEnvironmentToken
312312
313313 if (preExecute) {
314314 preExecute(this . steps, repo)
315315 }
316-
317- if (repo. type?. toLowerCase() == PipelineConfig . REPO_TYPE_ODS_CODE ) {
318- if (this . project. isAssembleMode && name == PipelinePhases . BUILD ) {
319- executeODSComponent(repo, baseDir)
320- } else if (this . project. isPromotionMode && name == PipelinePhases . DEPLOY ) {
321- new DeployOdsComponent (project, steps, git, logger). run(repo, baseDir)
322- } else if (this . project. isAssembleMode && name == PipelinePhases . FINALIZE ) {
323- new FinalizeOdsComponent (project, steps, git, logger). run(repo, baseDir)
324- } else {
325- this . logger. debug(" Repo '${ repo.id} ' is of type ODS Code Component. Nothing to do in phase '${ name} ' for target environment '${ targetEnvToken} '." )
326- }
327- } else if (repo. type?. toLowerCase() == PipelineConfig . REPO_TYPE_ODS_SERVICE ) {
328- if (this . project. isAssembleMode && name == PipelinePhases . BUILD ) {
329- executeODSComponent(repo, baseDir)
330- } else if (this . project. isPromotionMode && name == PipelinePhases . DEPLOY ) {
331- new DeployOdsComponent (project, steps, git, logger). run(repo, baseDir)
332- } else if (this . project. isAssembleMode && PipelinePhases . FINALIZE ) {
333- new FinalizeOdsComponent (project, steps, git, logger). run(repo, baseDir)
334- } else {
335- this . logger. debug(" Repo '${ repo.id} ' is of type ODS Service Component. Nothing to do in phase '${ name} ' for target environment '${ targetEnvToken} '." )
336- }
337- } else if (repo. type?. toLowerCase() == PipelineConfig . REPO_TYPE_ODS_TEST ) {
338- if (name == PipelinePhases . TEST ) {
339- executeODSComponent(repo, baseDir)
316+ // force this to happen on master - if an agent is needed, the closure has to
317+ // take care about it.
318+ this . steps. node {
319+ // when a node switch happens, jenkins creates a new dir @xxx - so we need to copy.
320+ def currentNodeBaseDir = " ${ this.steps.env.WORKSPACE} /${ REPOS_BASE_DIR} /${ repo.id} "
321+ this . steps. sh " cp -r ${ currentBaseDir} ${ currentNodeBaseDir} "
322+
323+ if (repo. type?. toLowerCase() == PipelineConfig . REPO_TYPE_ODS_CODE ) {
324+ if (this . project. isAssembleMode && name == PipelinePhases . BUILD ) {
325+ executeODSComponent(repo, currentNodeBaseDir)
326+ } else if (this . project. isPromotionMode && name == PipelinePhases . DEPLOY ) {
327+ new DeployOdsComponent (project, steps, git, logger). run(repo, currentNodeBaseDir)
328+ } else if (this . project. isAssembleMode && name == PipelinePhases . FINALIZE ) {
329+ new FinalizeOdsComponent (project, steps, git, logger). run(repo, currentNodeBaseDir)
330+ } else {
331+ this . logger. debug(" Repo '${ repo.id} ' is of type ODS Code Component. Nothing to do in phase '${ name} ' for target environment '${ targetEnvToken} '." )
332+ }
333+ } else if (repo. type?. toLowerCase() == PipelineConfig . REPO_TYPE_ODS_SERVICE ) {
334+ if (this . project. isAssembleMode && name == PipelinePhases . BUILD ) {
335+ executeODSComponent(repo, currentNodeBaseDir)
336+ } else if (this . project. isPromotionMode && name == PipelinePhases . DEPLOY ) {
337+ new DeployOdsComponent (project, steps, git, logger). run(repo, currentNodeBaseDir)
338+ } else if (this . project. isAssembleMode && PipelinePhases . FINALIZE ) {
339+ new FinalizeOdsComponent (project, steps, git, logger). run(repo, currentNodeBaseDir)
340+ } else {
341+ this . logger. debug(" Repo '${ repo.id} ' is of type ODS Service Component. Nothing to do in phase '${ name} ' for target environment '${ targetEnvToken} '." )
342+ }
343+ } else if (repo. type?. toLowerCase() == PipelineConfig . REPO_TYPE_ODS_TEST ) {
344+ if (name == PipelinePhases . TEST ) {
345+ executeODSComponent(repo, currentNodeBaseDir)
346+ } else {
347+ this . logger. debug(" Repo '${ repo.id} ' is of type ODS Test Component. Nothing to do in phase '${ name} ' for target environment '${ targetEnvToken} '." )
348+ }
340349 } else {
341- this . logger. debug(" Repo '${ repo.id} ' is of type ODS Test Component. Nothing to do in phase '${ name} ' for target environment '${ targetEnvToken} '." )
342- }
343- } else {
344- def phaseConfig = repo. pipelineConfig. phases ? repo. pipelineConfig. phases[name] : null
345- if (phaseConfig) {
346- def label = " ${ repo.id} (${ repo.url} )"
347-
348- if (phaseConfig. type == PipelineConfig . PHASE_EXECUTOR_TYPE_MAKEFILE ) {
349- this . steps. dir(baseDir) {
350- def steps = " make ${ phaseConfig.target} "
351- this . steps. sh script : steps, label : label
352- }
353- } else if (phaseConfig. type == PipelineConfig . PHASE_EXECUTOR_TYPE_SHELLSCRIPT ) {
354- this . steps. dir(baseDir) {
355- def steps = " ./scripts/${ phaseConfig.steps} "
356- this . steps. sh script : steps, label : label
350+ def phaseConfig = repo. pipelineConfig. phases ? repo. pipelineConfig. phases[name] : null
351+ if (phaseConfig) {
352+ def label = " ${ repo.id} (${ repo.url} )"
353+
354+ if (phaseConfig. type == PipelineConfig . PHASE_EXECUTOR_TYPE_MAKEFILE ) {
355+ this . steps. dir(currentNodeBaseDir) {
356+ def steps = " make ${ phaseConfig.target} "
357+ this . steps. sh script : steps, label : label
358+ }
359+ } else if (phaseConfig. type == PipelineConfig . PHASE_EXECUTOR_TYPE_SHELLSCRIPT ) {
360+ this . steps. dir(currentNodeBaseDir) {
361+ def steps = " ./scripts/${ phaseConfig.steps} "
362+ this . steps. sh script : steps, label : label
363+ }
357364 }
365+ } else {
366+ this . logger. debug(" Repo '${ repo.id} ' is of type '${ repo.type} '. Nothing to do in phase '${ name} ' for target environment '${ targetEnvToken} '." )
358367 }
359- } else {
360- this . logger. debug(" Repo '${ repo.id} ' is of type '${ repo.type} '. Nothing to do in phase '${ name} ' for target environment '${ targetEnvToken} '." )
361368 }
362369 }
363-
370+ // we keep this outside the node, as there are various code pieces in the different stages
364371 if (postExecute) {
365372 postExecute(this . steps, repo)
366373 }
0 commit comments