use of hudson.model.StringParameterValue in project workflow-cps-plugin by jenkinsci.
the class SnippetizerTest method buildTriggerStep.
@Test
public void buildTriggerStep() throws Exception {
BuildTriggerStep step = new BuildTriggerStep("downstream");
st.assertRoundTrip(step, "build 'downstream'");
step.setParameters(Arrays.asList(new StringParameterValue("branch", "default"), new BooleanParameterValue("correct", true)));
if (StringParameterDefinition.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) {
st.assertRoundTrip(step, "build job: 'downstream', parameters: [string(name: 'branch', value: 'default'), booleanParam(name: 'correct', value: true)]");
} else {
// TODO 2.x delete
st.assertRoundTrip(step, "build job: 'downstream', parameters: [[$class: 'StringParameterValue', name: 'branch', value: 'default'], [$class: 'BooleanParameterValue', name: 'correct', value: true]]");
}
}
use of hudson.model.StringParameterValue in project workflow-cps-plugin by jenkinsci.
the class CpsScmFlowDefinitionTest method usingParameter.
@Issue("JENKINS-28447")
@Test
public void usingParameter() throws Exception {
sampleRepo.init();
sampleRepo.write("flow.groovy", "echo 'version one'");
sampleRepo.git("add", "flow.groovy");
sampleRepo.git("commit", "--message=one");
sampleRepo.git("tag", "one");
sampleRepo.write("flow.groovy", "echo 'version two'");
sampleRepo.git("commit", "--all", "--message=two");
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
CpsScmFlowDefinition def = new CpsScmFlowDefinition(new GitSCM(Collections.singletonList(new UserRemoteConfig(sampleRepo.fileUrl(), null, null, null)), Collections.singletonList(new BranchSpec("${VERSION}")), false, Collections.<SubmoduleConfig>emptyList(), null, null, Collections.<GitSCMExtension>emptyList()), "flow.groovy");
// TODO SCMFileSystem.of cannot pick up build parameters
def.setLightweight(false);
p.setDefinition(def);
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("VERSION", "master")));
r.assertLogContains("version two", r.assertBuildStatusSuccess(p.scheduleBuild2(0)));
r.assertLogContains("version one", r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("VERSION", "one")))));
}
use of hudson.model.StringParameterValue in project vsphere-cloud-plugin by jenkinsci.
the class CloudSelectorParameter method createValue.
@Override
public ParameterValue createValue(StaplerRequest req, JSONObject jo) {
StringParameterValue value = req.bindJSON(StringParameterValue.class, jo);
value.setDescription(getDescription());
return checkValue(value);
}
use of hudson.model.StringParameterValue in project generic-webhook-trigger-plugin by jenkinsci.
the class GenericTrigger method addAllParametersFromParameterizedJob.
/**
* To keep any default values set there.
*/
private void addAllParametersFromParameterizedJob(final Job<?, ?> job, final List<StringParameterValue> parameterList) {
final ParametersDefinitionProperty parametersDefinitionProperty = job.getProperty(ParametersDefinitionProperty.class);
if (parametersDefinitionProperty != null) {
for (final ParameterDefinition parameterDefinition : parametersDefinitionProperty.getParameterDefinitions()) {
final String param = parameterDefinition.getName();
final ParameterValue defaultParameterValue = parameterDefinition.getDefaultParameterValue();
if (defaultParameterValue != null) {
final String value = defaultParameterValue.getValue().toString();
if (!isNullOrEmpty(value)) {
final StringParameterValue parameter = new StringParameterValue(param, value);
parameterList.add(parameter);
}
}
}
}
}
use of hudson.model.StringParameterValue in project promoted-builds-plugin by jenkinsci.
the class SelfPromotionInheritanceTest method testPromotionEnvironmentShouldIncludeTargetParameters.
@Test
@Issue("JENKINS-22679")
public void testPromotionEnvironmentShouldIncludeTargetParameters() throws Exception {
String paramName = "param";
InheritanceProjectsPair inheritanceProjectPair = j.createInheritanceProjectDerivedWithBase();
// promote if the downstream passes
JobPropertyImpl promotion = new JobPropertyImpl(inheritanceProjectPair.getBase());
inheritanceProjectPair.getBase().addProperty(promotion);
// TODO review this property asignment after https://issues.jenkins-ci.org/browse/JENKINS-34831 is fixed
inheritanceProjectPair.getBase().addProperty(new ParametersDefinitionProperty(new StringParameterDefinition(paramName, "")));
inheritanceProjectPair.getDerived().addProperty(new ParametersDefinitionProperty(new StringParameterDefinition(paramName, "")));
PromotionProcess promo1 = promotion.addProcess("promo1");
promo1.conditions.add(new SelfPromotionCondition(false));
// fire ItemListeners, this includes ArtifactArchiver,Migrator to make this test compatible with jenkins 1.575+
fireItemListeners();
String paramValue = "someString";
j.assertBuildStatusSuccess(inheritanceProjectPair.getDerived().scheduleBuild2(0, new Cause.UserCause(), new ParametersAction(new StringParameterValue(paramName, paramValue))));
// internally, the promotion is still an asynchronous process. It just happens
// right away after the build is complete.
j.waitUntilNoActivity();
// rebind
promotion = inheritanceProjectPair.getDerived().getProperty(JobPropertyImpl.class, /*Forcing inheritance as temporary hack for inheritance plugin 1.53
because that version of the plugin uses inheritance only for certain predefined cases:
-specific methods on the call stack
-url paths.
This has been changed as pull request https://github.com/i-m-c/jenkins-inheritance-plugin/pull/40
*/
IMode.INHERIT_FORCED);
promo1 = promotion.getItem("promo1");
// verify that the promotion's environment contains the parameter from the target build.
Promotion pb = promo1.getBuildByNumber(1);
assertEquals(paramValue, pb.getEnvironment(TaskListener.NULL).get(paramName, null));
}
Aggregations