Greetings everyone,
I want to create a button where whenever it clicks it takes the value of dropdown that I have and set it as <h1> on the same page, can anyone help with this one?
Action class code:
package io.jenkins.plugins.sample;
import hudson.model.Run;
import hudson.util.ListBoxModel;
import jenkins.model.RunAction2;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
public class PipelinePromotionAction implements RunAction2 {
private transient Run r;
private String status;
@DataBoundConstructor
public PipelinePromotionAction(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
@DataBoundSetter
public void setStatus(String status) {
this.status = status;
}
@Override
public void onAttached(Run<?, ?> r) {
this.r = r;
}
@Override
public void onLoad(Run<?, ?> r) {
this.r = r;
}
public Run getR() {
return r;
}
@Override
public String getIconFileName() {
return "star.png";
}
@Override
public String getDisplayName() {
return "Manual Promotion";
}
@Override
public String getUrlName() {
return "promotion";
}
}
And here is the jelly code:
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<l:layout title="Promotions tab">
<l:side-panel>
<st:include page="sidepanel.jelly" it="${it.r}" optional="true" />
</l:side-panel>
<l:main-panel>
<h1 id="header_status">
Status: ${it.status}
</h1>
<div>
<f:entry title="Choose promotion status" field="status">
<select name="status">
<option value="promoted">Promoted</option>
<option value="not_promoted">Not promoted</option>
</select>
</f:entry>
<button>Click me</button>
</div>
</l:main-panel>
</l:layout>
</j:jelly>