Workaround pre-upgrade desync of formula and jenkins itself
PROD-37234
Change-Id: I656be9cb667d2edfd9f4212d6c73c1cf0f313d2f
diff --git a/_states/jenkins_security.py b/_states/jenkins_security.py
index 785c56c..aa5b9fb 100644
--- a/_states/jenkins_security.py
+++ b/_states/jenkins_security.py
@@ -143,6 +143,19 @@
:returns: salt-specified state dict
"""
template = __salt__['jenkins_common.load_template'](
+ 'salt://jenkins/files/groovy/security.git_ssh_host_key_strategy_precheck.template',
+ __env__)
+ result = __salt__['jenkins_common.api_call']('git_ssh_host_key_strategy_precheck',
+ template, ["FOUND"], {}, "")
+ if not result['result']:
+ return {
+ 'name': name,
+ 'changes': {},
+ 'result': True,
+ 'comment': 'git_ssh_host_key_strategy is not applicable for installed version of git plugin, skipping',
+ }
+
+ template = __salt__['jenkins_common.load_template'](
'salt://jenkins/files/groovy/security.git_ssh_host_key_strategy.template',
__env__)
return __salt__['jenkins_common.api_call'](name, template,
diff --git a/jenkins/files/groovy/security.git_ssh_host_key_strategy_precheck.template b/jenkins/files/groovy/security.git_ssh_host_key_strategy_precheck.template
new file mode 100644
index 0000000..28ba0f5
--- /dev/null
+++ b/jenkins/files/groovy/security.git_ssh_host_key_strategy_precheck.template
@@ -0,0 +1,12 @@
+#!groovy
+// This template required to check if git plugin's classes are available (strict types sometimes painful)
+import org.jenkinsci.plugins.gitclient.verifier.*
+
+def instance = Jenkins.getInstance().getDescriptor("org.jenkinsci.plugins.gitclient.GitHostKeyVerificationConfiguration")
+
+if (instance){
+ print ("FOUND")
+}
+else {
+ print ("SKIP")
+}
\ No newline at end of file