Check casc version to match changes in YamlSource
Check for casc version 1.41 or to match the api changes to YamlSource
This commit is contained in:
		
							parent
							
								
									ee01c4c028
								
							
						
					
					
						commit
						2c79c128c5
					
				|  | @ -45,6 +45,8 @@ func (c *configurationAsCode) Ensure(jenkins *v1alpha2.Jenkins) (requeue bool, e | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const applyConfigurationAsCodeGroovyScriptFmt = ` | const applyConfigurationAsCodeGroovyScriptFmt = ` | ||||||
|  | import hudson.util.VersionNumber | ||||||
|  | 
 | ||||||
| String[] configContent = ['''%s'''] | String[] configContent = ['''%s'''] | ||||||
| def configSb = new StringBuffer() | def configSb = new StringBuffer() | ||||||
| for (int i=0; i<configContent.size(); i++) { | for (int i=0; i<configContent.size(); i++) { | ||||||
|  | @ -53,7 +55,20 @@ for (int i=0; i<configContent.size(); i++) { | ||||||
| 
 | 
 | ||||||
| def stream = new ByteArrayInputStream(configSb.toString().getBytes('UTF-8')) | def stream = new ByteArrayInputStream(configSb.toString().getBytes('UTF-8')) | ||||||
| 
 | 
 | ||||||
| def source = new io.jenkins.plugins.casc.yaml.YamlSource(stream, io.jenkins.plugins.casc.yaml.YamlSource.READ_FROM_INPUTSTREAM) | def plugin = jenkins.model.Jenkins.instance.getPluginManager().whichPlugin(io.jenkins.plugins.casc.ConfigurationAsCode) | ||||||
|  | def version = plugin.getVersionNumber() | ||||||
|  | 
 | ||||||
|  | def source | ||||||
|  | 
 | ||||||
|  | switch (version) { | ||||||
|  | 	case { it.isNewerThanOrEqualTo(new VersionNumber("1.41")) }: | ||||||
|  | 		source = new io.jenkins.plugins.casc.yaml.YamlSource(stream) | ||||||
|  | 		break | ||||||
|  | 	default: | ||||||
|  | 		source = new io.jenkins.plugins.casc.yaml.YamlSource(stream, io.jenkins.plugins.casc.yaml.YamlSource.READ_FROM_INPUTSTREAM) | ||||||
|  | 		break | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| io.jenkins.plugins.casc.ConfigurationAsCode.get().configureWith(source) | io.jenkins.plugins.casc.ConfigurationAsCode.get().configureWith(source) | ||||||
| ` | ` | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue