Skip to content

Commit

Permalink
MPL-52 Fix for issue with restore of the MPL state after restart (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei Parshev committed Feb 19, 2020
1 parent 3917527 commit f16492d
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/com/griddynamics/devops/mpl/MPLManager.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,29 @@

package com.griddynamics.devops.mpl

import com.cloudbees.groovy.cps.NonCPS

import com.griddynamics.devops.mpl.MPLException
import com.griddynamics.devops.mpl.MPLConfig
import com.griddynamics.devops.mpl.Helper

/**
* Object to help with MPL pipelines configuration & poststeps
*
* @author Sergei Parshev <[email protected]>
*/
@Singleton
class MPLManager implements Serializable {
/**
* Simple realization of a singleton
*/
private static inst = null

public static getInstance() {
if( ! inst )
inst = new MPLManager()
return inst
}

/** List of paths which is used to find modules in libraries */
private List modulesLoadPaths = ['com/griddynamics/devops/mpl']

Expand Down Expand Up @@ -246,4 +262,22 @@ class MPLManager implements Serializable {
public popActiveModule() {
activeModules.pop()
}

/**
* Restore the static object state if the pipeline was interrupted
*
* This function helps to make sure the MPL object will be restored
* if jenkins was restarted during the pipeline execution. It will
* work if the MPL object is stored in the pipeline:
*
* var/MPLPipeline.groovy:
* ...
* def MPL = MPLPipelineConfig(body, [
* ...
*/
@NonCPS
private void readObject(java.io.ObjectInputStream inp) throws IOException, ClassNotFoundException {
inp.defaultReadObject()
inst = this
}
}

0 comments on commit f16492d

Please sign in to comment.