org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable Java Examples
The following examples show how to use
org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KubernetesDeclarativeAgentTest.java From kubernetes-plugin with Apache License 2.0 | 6 votes |
@Issue({"JENKINS-41758", "JENKINS-57827", "JENKINS-60886"}) @Test public void declarative() throws Exception { assertNotNull(createJobThenScheduleRun()); r.assertBuildStatusSuccess(r.waitForCompletion(b)); r.assertLogContains("Apache Maven 3.3.9", b); r.assertLogContains("INSIDE_CONTAINER_ENV_VAR = " + CONTAINER_ENV_VAR_VALUE + "\n", b); r.assertLogContains("OUTSIDE_CONTAINER_ENV_VAR = " + CONTAINER_ENV_VAR_VALUE + "\n", b); FlowNode podTemplateNode = new DepthFirstScanner().findFirstMatch(b.getExecution(), Predicates.and(new NodeStepTypePredicate("podTemplate"), FlowScanningUtils.hasActionPredicate(ArgumentsAction.class))); assertNotNull("recorded arguments for podTemplate", podTemplateNode); Map<String, Object> arguments = podTemplateNode.getAction(ArgumentsAction.class).getArguments(); @SuppressWarnings("unchecked") List<UninstantiatedDescribable> containers = (List<UninstantiatedDescribable>) arguments.get("containers"); assertNotNull(containers); assertFalse("no junk in arguments: " + arguments, containers.get(0).getArguments().containsKey("alwaysPullImage")); FlowNode containerNode = new DepthFirstScanner().findFirstMatch(b.getExecution(), Predicates.and(new NodeStepTypePredicate("container"), FlowScanningUtils.hasActionPredicate(ArgumentsAction.class))); assertNotNull("recorded arguments for container", containerNode); // JENKINS-60886 UninstantiatedDescribable podRetention = (UninstantiatedDescribable) arguments.get("podRetention"); assertNotNull(podRetention); assertTrue(podRetention.getModel().getType().equals(OnFailure.class)); }
Example #2
Source File: DockerNodeStepTest.java From docker-plugin with MIT License | 6 votes |
@Test public void defaults() { story.then(r -> { DockerNodeStep s = new DockerNodeStep("foo"); s.setCredentialsId(""); s.setDockerHost(""); s.setRemoteFs(""); UninstantiatedDescribable uninstantiated = new DescribableModel<>(DockerNodeStep.class).uninstantiate2(s); assertEquals(uninstantiated.toString(), Collections.singleton("image"), uninstantiated.getArguments().keySet()); r.jenkins.clouds.add(new DockerCloud("whatever", new DockerAPI(new DockerServerEndpoint("unix:///var/run/docker.sock", null)), Collections.emptyList())); WorkflowJob j = r.createProject(WorkflowJob.class, "p"); j.setDefinition(new CpsFlowDefinition( dockerNodeWithImage("openjdk:8") + " {\n" + " sh 'java -version && whoami && pwd && touch stuff && ls -lat . ..'\n" + "}\n", true)); r.buildAndAssertSuccess(j); }); }
Example #3
Source File: RegistryEndpointStep.java From docker-workflow-plugin with MIT License | 5 votes |
@Override public UninstantiatedDescribable uninstantiate(Step step) throws UnsupportedOperationException { RegistryEndpointStep s = (RegistryEndpointStep) step; Map<String, Object> args = new TreeMap<>(); args.put("url", s.registry.getUrl()); args.put("credentialsId", s.registry.getCredentialsId()); args.put("toolName", s.toolName); args.values().removeAll(Collections.singleton(null)); return new UninstantiatedDescribable(args); }
Example #4
Source File: GitHubSCMSource.java From github-branch-source-plugin with MIT License | 5 votes |
@Nonnull public UninstantiatedDescribable customUninstantiate(@Nonnull UninstantiatedDescribable ud) { Map<String, Object> scmArguments = new TreeMap<>(ud.getArguments()); scmArguments.remove("repositoryUrl"); scmArguments.remove("configuredByUrl"); return ud.withArguments(scmArguments); }
Example #5
Source File: GitHubSCMSourceTraitsTest.java From github-branch-source-plugin with MIT License | 5 votes |
@Test public void given__configuredInstance__when__uninstantiating__then__deprecatedFieldsIgnored() throws Exception { GitHubSCMSource instance = new GitHubSCMSource("repo-owner", "repo", null, false); instance.setId("test"); DescribableModel model = DescribableModel.of(GitHubSCMSource.class); UninstantiatedDescribable ud = model.uninstantiate2(instance); Map<String, Object> udMap = ud.toMap(); GitHubSCMSource recreated = (GitHubSCMSource) model.instantiate(udMap); assertThat(DescribableModel.uninstantiate2_(recreated).toString(), is("@github(id=test,repoOwner=repo-owner,repository=repo)") ); recreated.setBuildOriginBranch(true); recreated.setBuildOriginBranchWithPR(false); recreated.setBuildOriginPRHead(false); recreated.setBuildOriginPRMerge(true); recreated.setBuildForkPRHead(true); recreated.setBuildForkPRMerge(false); recreated.setIncludes("i*"); recreated.setExcludes("production"); recreated.setScanCredentialsId("foo"); assertThat(DescribableModel.uninstantiate2_(recreated).toString(), is("@github(" + "credentialsId=foo," + "id=test," + "repoOwner=repo-owner," + "repository=repo," + "traits=[" + "@gitHubBranchDiscovery$org.jenkinsci.plugins.github_branch_source.BranchDiscoveryTrait(strategyId=1), " + "@gitHubPullRequestDiscovery$OriginPullRequestDiscoveryTrait(strategyId=1), " + "@gitHubForkDiscovery$ForkPullRequestDiscoveryTrait(" + "strategyId=2," + "trust=@gitHubTrustPermissions$TrustPermission()), " + "@headWildcardFilter$WildcardSCMHeadFilterTrait(excludes=production,includes=i*)])") ); }