Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED JENKINS-49057] List All Options for Ansible Playbook Pipeline Syntax Generator #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExtraVar> extraVars = null;
private String extras = null;
private boolean colorized = false;
private int forks = 0;
Expand Down Expand Up @@ -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<String, Object> extraVars) {
if (this.extraVars == null) {
List<ExtraVar> extraVarList = new ArrayList<ExtraVar>();
for (Map.Entry<String, Object> 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<ExtraVar> extraVars) {
this.extraVars = extraVars;
}

Expand Down Expand Up @@ -239,7 +261,12 @@ public String getStartAtTask() {
return startAtTask;
}

@Deprecated
public Map<String, Object> getExtraVars() {
return null;
}

public List<ExtraVar> getExtraVariables() {
return extraVars;
}

Expand Down Expand Up @@ -328,27 +355,6 @@ public static final class AnsiblePlaybookExecution extends AbstractSynchronousNo
@StepContextParameter
private transient Computer computer;

private List<ExtraVar> convertExtraVars(Map<String, Object> extraVars) {
if (extraVars == null) {
return null;
}
List<ExtraVar> extraVarList = new ArrayList<ExtraVar>();
for (Map.Entry<String, Object> 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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<f:entry field="inventory" title="Inventory file path in workspace">
<f:textbox/>
</f:entry>
<f:entry field="inventoryContent" title="Inventory file content">
<f:textbox/>
</f:entry>
<f:entry field="credentialsId" title="SSH connection credentials">
<c:select/>
</f:entry>
Expand Down Expand Up @@ -48,6 +51,26 @@
<f:entry field="colorized" title="${%Colorized output}">
<f:checkbox default="false" />
</f:entry>
<f:entry title="${%Extra Variables}">
<f:repeatable add="${%Add Extra Variable}" field="extraVariables" noAddButton="false">
<table width="100%">
<f:entry title="${%Key}" field="key">
<f:textbox clazz="required" />
</f:entry>
<f:entry title="${%Value}" field="value">
<f:textbox clazz="required" />
</f:entry>
<f:entry title="${%Hidden variable in build log}" field="hidden">
<f:checkbox default="false" />
</f:entry>
<f:entry>
<div align="right" class="repeatable-delete show-if-only">
<f:repeatableDeleteButton value="${%Delete Extra Variable}" />
</div>
</f:entry>
</table>
</f:repeatable>
</f:entry>
<f:entry field="extras" title="Extra parameters">
<f:textbox/>
</f:entry>
Expand Down