From f1686547474d51d9fa35e32a25f02050bf48ea57 Mon Sep 17 00:00:00 2001 From: Michael Cresswell Date: Tue, 30 Jan 2018 20:12:23 -0800 Subject: [PATCH] [FIXED JENKINS-49057] List All Options for Ansible Playbook Pipeline Syntax Generator extraVariables and inventoryContent have been added to the generator extraVars is deprecated since maps do not work with the generator --- .../ansible/workflow/AnsiblePlaybookStep.java | 54 ++++++++++--------- .../workflow/AnsiblePlaybookStep/config.jelly | 23 ++++++++ 2 files changed, 53 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/ansible/workflow/AnsiblePlaybookStep.java b/src/main/java/org/jenkinsci/plugins/ansible/workflow/AnsiblePlaybookStep.java index defb3a0..067f4a9 100644 --- a/src/main/java/org/jenkinsci/plugins/ansible/workflow/AnsiblePlaybookStep.java +++ b/src/main/java/org/jenkinsci/plugins/ansible/workflow/AnsiblePlaybookStep.java @@ -73,7 +73,7 @@ public class AnsiblePlaybookStep extends AbstractStepImpl { private String tags = null; private String skippedTags = null; private String startAtTask = null; - private Map extraVars = null; + private List extraVars = null; private String extras = null; private boolean colorized = false; private int forks = 0; @@ -154,8 +154,30 @@ public void setStartAtTask(String startAtTask) { this.startAtTask = Util.fixEmptyAndTrim(startAtTask); } + @Deprecated @DataBoundSetter - public void setExtraVars(Map extraVars) { + public void setExtraVars(Map extraVars) { + if (this.extraVars == null) { + List extraVarList = new ArrayList(); + for (Map.Entry entry: extraVars.entrySet()) { + ExtraVar var = new ExtraVar(); + var.setKey(entry.getKey()); + Object o = entry.getValue(); + if (o instanceof Map) { + var.setValue(((Map)o).get("value").toString()); + var.setHidden((Boolean)((Map)o).get("hidden")); + } else { + var.setValue(o.toString()); + var.setHidden(false); + } + extraVarList.add(var); + } + setExtraVariables(extraVarList); + } + } + + @DataBoundSetter + public void setExtraVariables(List extraVars) { this.extraVars = extraVars; } @@ -239,7 +261,12 @@ public String getStartAtTask() { return startAtTask; } + @Deprecated public Map getExtraVars() { + return null; + } + + public List getExtraVariables() { return extraVars; } @@ -328,27 +355,6 @@ public static final class AnsiblePlaybookExecution extends AbstractSynchronousNo @StepContextParameter private transient Computer computer; - private List convertExtraVars(Map extraVars) { - if (extraVars == null) { - return null; - } - List extraVarList = new ArrayList(); - for (Map.Entry entry: extraVars.entrySet()) { - ExtraVar var = new ExtraVar(); - var.setKey(entry.getKey()); - Object o = entry.getValue(); - if (o instanceof Map) { - var.setValue(((Map)o).get("value").toString()); - var.setHidden((Boolean)((Map)o).get("hidden")); - } else { - var.setValue(o.toString()); - var.setHidden(false); - } - extraVarList.add(var); - } - return extraVarList; - } - @Override protected Void run() throws Exception { Inventory inventory = null; @@ -373,7 +379,7 @@ protected Void run() throws Exception { builder.setTags(step.getTags()); builder.setStartAtTask(step.getStartAtTask()); builder.setSkippedTags(step.getSkippedTags()); - builder.setExtraVars(convertExtraVars(step.extraVars)); + builder.setExtraVars(step.getExtraVariables()); builder.setAdditionalParameters(step.getExtras()); builder.setHostKeyChecking(step.isHostKeyChecking()); builder.setUnbufferedOutput(true); diff --git a/src/main/resources/org/jenkinsci/plugins/ansible/workflow/AnsiblePlaybookStep/config.jelly b/src/main/resources/org/jenkinsci/plugins/ansible/workflow/AnsiblePlaybookStep/config.jelly index 761c741..444be2a 100644 --- a/src/main/resources/org/jenkinsci/plugins/ansible/workflow/AnsiblePlaybookStep/config.jelly +++ b/src/main/resources/org/jenkinsci/plugins/ansible/workflow/AnsiblePlaybookStep/config.jelly @@ -9,6 +9,9 @@ + + + @@ -48,6 +51,26 @@ + + + + + + + + + + + + + +
+ +
+
+
+
+