|
23 | 23 |
|
24 | 24 | package com.griddynamics.devops.mpl |
25 | 25 |
|
| 26 | +import com.cloudbees.groovy.cps.NonCPS |
| 27 | + |
| 28 | +import com.griddynamics.devops.mpl.MPLException |
| 29 | +import com.griddynamics.devops.mpl.MPLConfig |
| 30 | +import com.griddynamics.devops.mpl.Helper |
| 31 | + |
26 | 32 | /** |
27 | 33 | * Object to help with MPL pipelines configuration & poststeps |
28 | 34 | * |
29 | 35 | * @author Sergei Parshev <[email protected]> |
30 | 36 | */ |
31 | | -@Singleton |
32 | 37 | class MPLManager implements Serializable { |
| 38 | + /** |
| 39 | + * Simple realization of a singleton |
| 40 | + */ |
| 41 | + private static inst = null |
| 42 | + |
| 43 | + public static getInstance() { |
| 44 | + if( ! inst ) |
| 45 | + inst = new MPLManager() |
| 46 | + return inst |
| 47 | + } |
| 48 | + |
33 | 49 | /** List of paths which is used to find modules in libraries */ |
34 | 50 | private List modulesLoadPaths = ['com/griddynamics/devops/mpl'] |
35 | 51 |
|
@@ -246,4 +262,22 @@ class MPLManager implements Serializable { |
246 | 262 | public popActiveModule() { |
247 | 263 | activeModules.pop() |
248 | 264 | } |
| 265 | + |
| 266 | + /** |
| 267 | + * Restore the static object state if the pipeline was interrupted |
| 268 | + * |
| 269 | + * This function helps to make sure the MPL object will be restored |
| 270 | + * if jenkins was restarted during the pipeline execution. It will |
| 271 | + * work if the MPL object is stored in the pipeline: |
| 272 | + * |
| 273 | + * var/MPLPipeline.groovy: |
| 274 | + * ... |
| 275 | + * def MPL = MPLPipelineConfig(body, [ |
| 276 | + * ... |
| 277 | + */ |
| 278 | + @NonCPS |
| 279 | + private void readObject(java.io.ObjectInputStream inp) throws IOException, ClassNotFoundException { |
| 280 | + inp.defaultReadObject() |
| 281 | + inst = this |
| 282 | + } |
249 | 283 | } |
0 commit comments