-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MPL-52 Fix for issue with restore of the MPL state after restart (#52)
- Loading branch information
Sergei Parshev
committed
Feb 19, 2020
1 parent
3917527
commit f16492d
Showing
1 changed file
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'] | ||
|
||
|
@@ -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 | ||
} | ||
} |