use of hudson.model.ParametersDefinitionProperty in project workflow-cps-plugin by jenkinsci.
the class ParamsVariableTest method smokes.
@Issue("JENKINS-27295")
@Test
public void smokes() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("echo(/TEXT=${params.TEXT} FLAG=${params.FLAG ? 'yes' : 'no'} PASS=${params.PASS}/)", true));
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("TEXT", ""), new BooleanParameterDefinition("FLAG", false, null), new PasswordParameterDefinition("PASS", "", null)));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("TEXT", "hello"), new BooleanParameterValue("FLAG", true), new PasswordParameterValue("PASS", "s3cr3t"))));
r.assertLogContains("TEXT=hello", b);
r.assertLogContains("FLAG=yes", b);
r.assertLogContains("PASS=s3cr3t", b);
}
use of hudson.model.ParametersDefinitionProperty in project workflow-cps-plugin by jenkinsci.
the class ParamsVariableTest method nullValue.
@Issue("JENKINS-42367")
@Test
public void nullValue() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("echo(/TEXT=${params.TEXT}/)", true));
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("TEXT", "")));
r.assertLogContains("TEXT=null", r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("TEXT", /* not possible via UI, but to simulate other ParameterValue impls */
null)))));
}
use of hudson.model.ParametersDefinitionProperty in project workflow-cps-plugin by jenkinsci.
the class SnippetizerTest method generateSnippetForBuildTrigger.
@Issue("JENKINS-26093")
@Test
public void generateSnippetForBuildTrigger() throws Exception {
MockFolder d1 = r.createFolder("d1");
FreeStyleProject ds = d1.createProject(FreeStyleProject.class, "ds");
MockFolder d2 = r.createFolder("d2");
// Really this would be a WorkflowJob, but we cannot depend on that here, and it should not matter since we are just looking for Job:
FreeStyleProject us = d2.createProject(FreeStyleProject.class, "us");
ds.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("key", ""), new BooleanParameterDefinition("flag", false, "")));
String snippet;
if (StringParameterDefinition.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) {
snippet = "build job: '../d1/ds', parameters: [string(name: 'key', value: 'stuff'), booleanParam(name: 'flag', value: true)]";
} else {
// TODO 2.x delete
snippet = "build job: '../d1/ds', parameters: [[$class: 'StringParameterValue', name: 'key', value: 'stuff'], [$class: 'BooleanParameterValue', name: 'flag', value: true]]";
}
st.assertGenerateSnippet("{'stapler-class':'" + BuildTriggerStep.class.getName() + "', 'job':'../d1/ds', 'parameter': [{'name':'key', 'value':'stuff'}, {'name':'flag', 'value':true}]}", snippet, us.getAbsoluteUrl() + "configure");
}
use of hudson.model.ParametersDefinitionProperty in project promoted-builds-plugin by jenkinsci.
the class PromotionProcess method getDefaultParameterValuesAsEnvVars.
private static EnvVars getDefaultParameterValuesAsEnvVars(AbstractProject owner) {
EnvVars envVars = null;
ParametersDefinitionProperty parametersDefinitionProperty = (ParametersDefinitionProperty) owner.getProperty(ParametersDefinitionProperty.class);
if (parametersDefinitionProperty != null) {
envVars = new EnvVars();
for (ParameterDefinition parameterDefinition : parametersDefinitionProperty.getParameterDefinitions()) {
ParameterValue defaultParameterValue = parameterDefinition.getDefaultParameterValue();
if (defaultParameterValue != null) {
if (defaultParameterValue instanceof StringParameterValue) {
envVars.put(parameterDefinition.getName(), (String) defaultParameterValue.getValue());
}
}
}
EnvVars.resolve(envVars);
}
return envVars;
}
use of hudson.model.ParametersDefinitionProperty in project promoted-builds-plugin by jenkinsci.
the class PromotionProcessTest method testIsVisibleResolvesDefaultParameterValue.
@Test
public void testIsVisibleResolvesDefaultParameterValue() throws Exception {
FreeStyleProject project = j.createFreeStyleProject("project");
final List<ParameterDefinition> parameters = new ArrayList<ParameterDefinition>();
ParametersDefinitionProperty parametersProperty = new ParametersDefinitionProperty(parameters);
parameters.add(new StringParameterDefinition("Visibility", "false"));
project.addProperty(parametersProperty);
JobPropertyImpl jobProperty = new JobPropertyImpl(project);
project.addProperty(jobProperty);
PromotionProcess promotionProcess = jobProperty.addProcess("Promotion");
promotionProcess.isVisible = "${Visibility}";
assertFalse(promotionProcess.isVisible());
}
Aggregations