@Override public void recordLegacyName(F parent, J item, String legacyDirName) throws IOException { item.addProperty(new NameProperty(Normalizer.normalize(legacyDirName, Normalizer.Form.NFD))); } }
@Override public void recordLegacyName(F parent, J item, String legacyDirName) throws IOException { item.addProperty(new NameProperty(legacyDirName)); } }
@Override public void recordLegacyName(F parent, J item, String legacyDirName) throws IOException { item.addProperty(new NameProperty(rawDecode(legacyDirName))); } }
p.addProperty(new NameProperty(kid)); p.setDescription("created in round #" + round); } finally {
@Issue("JENKINS-29739") @Test public void generateSnippetForBuildTriggerSingle() throws Exception { FreeStyleProject ds = r.jenkins.createProject(FreeStyleProject.class, "ds1"); FreeStyleProject us = r.jenkins.createProject(FreeStyleProject.class, "us1"); ds.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("key", ""))); String snippet; if (StringParameterDefinition.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) { snippet = "build job: 'ds1', parameters: [string(name: 'key', value: 'stuff')]"; } else { // TODO 2.x delete snippet = "build job: 'ds1', parameters: [[$class: 'StringParameterValue', name: 'key', value: 'stuff']]"; } st.assertGenerateSnippet("{'stapler-class':'" + BuildTriggerStep.class.getName() + "', 'job':'ds1', 'parameter': {'name':'key', 'value':'stuff'}}", snippet, us.getAbsoluteUrl() + "configure"); }
p.addProperty(new NameProperty(kid)); p.setDescription("created in round #" + round); } finally {
@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"); }
/** * Creates a new freestyle project, builds it and ensures the rebuild action * isn't available on the project level. * * @throws Exception * Exception */ public void testWhenProjectWithoutParamsThenRebuildProjectIsDisabled() throws Exception { FreeStyleProject project = createFreeStyleProject(); project.scheduleBuild2(0); RebuildSettings settings = new RebuildSettings(false, true); project.addProperty(settings); project.save(); HtmlPage projectPage = createWebClient().getPage(project); WebAssert.assertLinkNotPresentWithText(projectPage, "Rebuild Last"); }
/** * Creates a new freestyle project, builds it and ensures the rebuild action * is available on the project level. * * @throws Exception * Exception */ public void testWhenProjectWithoutParamsThenRebuildProjectEnabled() throws Exception { FreeStyleProject project = createFreeStyleProject(); project.scheduleBuild2(0); RebuildSettings settings = new RebuildSettings(false, false); project.addProperty(settings); project.save(); HtmlPage projectPage = createWebClient().getPage(project); WebAssert.assertLinkPresentWithText(projectPage, "Rebuild Last"); }
new StringParameterDefinition(key, val, "") ); project.addProperty(pdb);
@Issue("SECURITY-158") @Test public void doFillCredentialsIdItems() throws Exception { r.jenkins.setSecurityRealm(r.createDummySecurityRealm()); ProjectMatrixAuthorizationStrategy as = new ProjectMatrixAuthorizationStrategy(); as.add(Jenkins.READ, "alice"); as.add(Jenkins.READ, "bob"); r.jenkins.setAuthorizationStrategy(as); FreeStyleProject p1 = r.createFreeStyleProject("p1"); FreeStyleProject p2 = r.createFreeStyleProject("p2"); p2.addProperty(new AuthorizationMatrixProperty(Collections.singletonMap(Item.CONFIGURE, Collections.singleton("bob")))); UsernamePasswordCredentialsImpl c = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, null, "test", "bob", "s3cr3t"); CredentialsProvider.lookupStores(r.jenkins).iterator().next().addCredentials(Domain.global(), c); assertCredentials("alice", null); assertCredentials("alice", p1); assertCredentials("alice", p2); assertCredentials("bob", null); assertCredentials("bob", p1); assertCredentials("bob", p2, c); } private void assertCredentials(String user, final Job<?,?> owner, Credentials... expected) {
@Bug(4271) @Test public void parameterizedBuildsBranch() throws Exception { m.hg(repo, "init"); m.touchAndCommit(repo, "trunk"); m.hg(repo, "update", "null"); m.hg(repo, "branch", "b"); m.touchAndCommit(repo, "variant"); FreeStyleProject p = j.createFreeStyleProject(); p.setScm(new MercurialSCM(hgInstallation(), repo.getPath(), "${BRANCH}", null, null, null, false)); // SECURITY-170 - have to use ParametersDefinitionProperty p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("BRANCH", "b"))); String log = m.buildAndCheck(p, "variant", new ParametersAction( new StringParameterValue("BRANCH", "b"))); assertTrue(log, log.contains("--rev b")); assertFalse(log, log.contains("--rev ${BRANCH}")); m.touchAndCommit(repo, "further-variant"); // the following assertion commented out as a part of the fix to // HUDSON-6126 // assertTrue(pollSCMChanges(p)); m.buildAndCheck(p, "further-variant", new ParametersAction( new StringParameterValue("BRANCH", "b"))); }
/** * Creates a new freestyle project and build with a parameter value whose * type is unknown to rebuild plugin. Rebuild and verify that an no * exception occurs and page is displayed correctly. * * {@link RebuildableParameterValue}. * * @throws Exception * Exception */ public void testRebuildUnsupportedUnknownParameterValue() throws Exception { WebClient wc = createWebClient(); FreeStyleProject project = createFreeStyleProject(); project.addProperty(new ParametersDefinitionProperty( new UnsupportedUnknownParameterDefinition("param1", "defaultValue"))); assertBuildStatusSuccess(project.scheduleBuild2(0, new Cause.RemoteCause("host", "note"), new ParametersAction(new UnsupportedUnknownParameterValue( "param1", "value1")))); FreeStyleBuild build = project.getLastBuild(); // it is trying to fallback and use the HtmlPage page = wc.getPage(build, "rebuild"); // Check the hardcoded description is showing properly. assertTrue(page.asText().contains( "Configuration page for UnsupportedUnknownParameterValue")); }
/** * Creates a new freestyle project and build with a parameter value whose * type is unknown to rebuild plugin. Verify that rebuild succeeds if that * parameter value supports {@link RebuildableParameterValue}. * * @throws Exception * Exception */ public void testRebuildSupportedUnknownParameterValue() throws Exception { WebClient wc = createWebClient(); FreeStyleProject project = createFreeStyleProject(); project.addProperty(new ParametersDefinitionProperty( new SupportedUnknownParameterDefinition("param1", "defaultValue"))); assertBuildStatusSuccess(project .scheduleBuild2(0, new Cause.RemoteCause("host", "note"), new ParametersAction( new SupportedUnknownParameterValue("param1", "value1")))); FreeStyleBuild build = project.getLastBuild(); HtmlPage page = wc.getPage(build, "rebuild"); assertTrue(page.asText(), page.asText().contains("This is a mark for test")); }
@Bug(9686) @Test public void pollingExpandsParameterDefaults() throws Exception { m.hg(repo, "init"); m.touchAndCommit(repo, "trunk"); m.hg(repo, "update", "null"); m.hg(repo, "branch", "b"); m.touchAndCommit(repo, "variant"); FreeStyleProject p = j.createFreeStyleProject(); p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("branch", "default"))); p.setScm(new MercurialSCM(hgInstallation(), repo.getPath(), "${branch}", null, null, null, false)); String log = m.buildAndCheck(p, "trunk", new ParametersAction(new StringParameterValue("branch", "default"))); assertTrue(log, log.contains("--rev default")); /* TODO cannot behave sensibly when workspace contains a branch build because the *current* trunk revision will be seen as new; would need to compare to all historical build records, or keep a separate workspace per branch: log = m.buildAndCheck(p, "variant", new ParametersAction(new StringParameterValue("branch", "b"))); assertTrue(log, log.contains("--rev b")); */ assertEquals(PollingResult.Change.NONE, m.pollSCMChanges(p).change); m.hg(repo, "update", "default"); m.touchAndCommit(repo, "trunk2"); assertEquals(PollingResult.Change.SIGNIFICANT, m.pollSCMChanges(p).change); }
/** * This test aims to verify that the variables defined in the "Properties Content" field, are availables in SCM Polling. */ @Ignore("TODO org.tmatesoft.svn.core.SVNException: svn: E175002: PROPFIND of '/trunk/hudson/test-projects/trivial-maven': 405 Method Not Allowed (https://svn.jenkins-ci.org)") @Issue("JENKINS-29340") @Test public void pollingWithEnvInject() throws Exception { FreeStyleProject project = jenkins.createFreeStyleProject(); EnvInjectJobPropertyInfo jobPropertyInfo = new EnvInjectJobPropertyInfo(null, "REPO=trivial-maven", null, null, null, false); EnvInjectJobProperty envInjectJobProperty = new EnvInjectJobProperty(); envInjectJobProperty.setOn(true); envInjectJobProperty.setInfo(jobPropertyInfo); project.addProperty(envInjectJobProperty); project.setScm(new SubversionSCM(REPO_URL)); TaskListener listener = jenkins.createTaskListener(); PollingResult poll = project.poll(listener); // If true means that parameters have been replaced correctly and we have a valid repository URL. assertTrue(poll.hasChanges()); jenkins.assertBuildStatusSuccess(project.scheduleBuild2(0).get()); } }
@Issue("JENKINS-22568") @Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void pollingWithChoiceParametersWithOutCurlyBraces() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); String repo = "https://svn.jenkins-ci.org/"; String path = "trunk/hudson/test-projects/trivial-maven/src/test/java/test"; p.setScm(new SubversionSCM("${REPO}" + path)); ParametersDefinitionProperty property = new ParametersDefinitionProperty(new ChoiceParameterDefinition("REPO", new String[] {repo, "test"}, "")); p.addProperty(property); FreeStyleBuild b = p.scheduleBuild2(0, new Cause.UserIdCause(), new ParametersAction(new StringParameterValue("REPO", repo))).get(); r.assertBuildStatus(Result.SUCCESS,b); assertTrue(b.getWorkspace().child("AppTest.java").exists()); // as a baseline, this shouldn't detect any change TaskListener listener = r.createTaskListener(); PollingResult poll = p.poll(listener); assertFalse("Polling shouldn't have any changes.", poll.hasChanges()); }
@Issue("JENKINS-22568") @Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void pollingWithDefaultParametersWithCurlyBraces() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); String repo = "https://svn.jenkins-ci.org/"; String path = "trunk/hudson/test-projects/trivial-ant/"; p.setScm(new SubversionSCM("${REPO}" + path)); ParametersDefinitionProperty property = new ParametersDefinitionProperty(new StringParameterDefinition("REPO", repo)); p.addProperty(property); FreeStyleBuild b = p.scheduleBuild2(0, new Cause.UserIdCause(), new ParametersAction(new StringParameterValue("REPO", repo))).get(); r.assertBuildStatus(Result.SUCCESS,b); assertTrue(b.getWorkspace().child("build.xml").exists()); // as a baseline, this shouldn't detect any change TaskListener listener = r.createTaskListener(); PollingResult poll = p.poll(listener); assertFalse("Polling shouldn't have any changes.", poll.hasChanges()); }
@Issue("JENKINS-22568") @Test @Ignore("TODO use docker-fixtures for a reproducible test case") public void pollingWithDefaultParametersWithOutCurlyBraces() throws Exception { FreeStyleProject p = r.createFreeStyleProject(); String repo = "https://svn.jenkins-ci.org"; String path = "/trunk/hudson/test-projects/trivial-ant/"; p.setScm(new SubversionSCM("$REPO" + path)); ParametersDefinitionProperty property = new ParametersDefinitionProperty(new StringParameterDefinition("REPO", repo)); p.addProperty(property); FreeStyleBuild b = p.scheduleBuild2(0, new Cause.UserIdCause(), new ParametersAction(new StringParameterValue("REPO", repo))).get(); r.assertBuildStatus(Result.SUCCESS,b); assertTrue(b.getWorkspace().child("build.xml").exists()); // as a baseline, this shouldn't detect any change TaskListener listener = r.createTaskListener(); PollingResult poll = p.poll(listener); assertFalse("Polling shouldn't have any changes.", poll.hasChanges()); }
/** * Creates a new freestyle project and builds the project with a string * parameter. If the build is succesful, a rebuild of the last build is * done. The rebuild on the project level should point to the last build * * @throws Exception * Exception */ public void testWhenProjectWithParamsThenRebuildProjectExecutesRebuildOfLastBuild() throws Exception { FreeStyleProject project = createFreeStyleProject(); project.addProperty(new ParametersDefinitionProperty( new StringParameterDefinition("name", "defaultValue"))); // Build (#1) project.scheduleBuild2(0, new Cause.UserIdCause(), new ParametersAction(new StringParameterValue("name", "test"))) .get(); HtmlPage rebuildConfigPage = createWebClient().getPage(project, "1/rebuild"); // Rebuild (#2) submit(rebuildConfigPage.getFormByName("config")); HtmlPage projectPage = createWebClient().getPage(project); WebAssert.assertLinkPresentWithText(projectPage, "Rebuild Last"); HtmlAnchor rebuildHref = projectPage.getAnchorByText("Rebuild Last"); assertEquals("Rebuild Last should point to the second build", "/" + project.getUrl() + "lastCompletedBuild/rebuild", rebuildHref.getHrefAttribute()); }