Java Code Examples for hudson.util.DescribableList#add()
The following examples show how to use
hudson.util.DescribableList#add() .
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: BitbucketCloudScmContentProviderTest.java From blueocean-plugin with MIT License | 6 votes |
private MultiBranchProject mockMbp(String credentialId, User user) { MultiBranchProject mbp = mock(MultiBranchProject.class); when(mbp.getName()).thenReturn("pipeline1"); when(mbp.getParent()).thenReturn(j.jenkins); BitbucketSCMSource scmSource = mock(BitbucketSCMSource.class); when(scmSource.getServerUrl()).thenReturn(apiUrl); when(scmSource.getCredentialsId()).thenReturn(credentialId); when(scmSource.getRepoOwner()).thenReturn(USER_UUID); when(scmSource.getRepository()).thenReturn("demo1"); when(mbp.getSCMSources()).thenReturn(Lists.<SCMSource>newArrayList(scmSource)); //mock blueocean credential provider stuff BlueOceanCredentialsProvider.FolderPropertyImpl folderProperty = mock(BlueOceanCredentialsProvider.FolderPropertyImpl.class); DescribableList<AbstractFolderProperty<?>, AbstractFolderPropertyDescriptor> properties = new DescribableList<AbstractFolderProperty<?>, AbstractFolderPropertyDescriptor>(mbp); properties.add(new BlueOceanCredentialsProvider.FolderPropertyImpl( user.getId(), credentialId, BlueOceanCredentialsProvider.createDomain(apiUrl) )); Domain domain = mock(Domain.class); when(domain.getName()).thenReturn(BitbucketCloudScm.DOMAIN_NAME); when(folderProperty.getDomain()).thenReturn(domain); when(mbp.getProperties()).thenReturn(properties); return mbp; }
Example 2
Source File: BitbucketServerScmContentProviderTest.java From blueocean-plugin with MIT License | 6 votes |
private MultiBranchProject mockMbp(String credentialId, User user) { MultiBranchProject mbp = mock(MultiBranchProject.class); when(mbp.getName()).thenReturn("pipeline1"); when(mbp.getParent()).thenReturn(j.jenkins); BitbucketSCMSource scmSource = mock(BitbucketSCMSource.class); when(scmSource.getServerUrl()).thenReturn(apiUrl); when(scmSource.getCredentialsId()).thenReturn(credentialId); when(scmSource.getRepoOwner()).thenReturn("TESTP"); when(scmSource.getRepository()).thenReturn("pipeline-demo-test"); when(mbp.getSCMSources()).thenReturn(Lists.<SCMSource>newArrayList(scmSource)); //mock blueocean credential provider stuff BlueOceanCredentialsProvider.FolderPropertyImpl folderProperty = mock(BlueOceanCredentialsProvider.FolderPropertyImpl.class); DescribableList<AbstractFolderProperty<?>, AbstractFolderPropertyDescriptor> properties = new DescribableList<AbstractFolderProperty<?>, AbstractFolderPropertyDescriptor>(mbp); properties.add(new BlueOceanCredentialsProvider.FolderPropertyImpl( user.getId(), credentialId, BlueOceanCredentialsProvider.createDomain(apiUrl) )); Domain domain = mock(Domain.class); when(domain.getName()).thenReturn(BitbucketServerScm.DOMAIN_NAME); when(folderProperty.getDomain()).thenReturn(domain); when(mbp.getProperties()).thenReturn(properties); return mbp; }
Example 3
Source File: GithubMockBase.java From blueocean-plugin with MIT License | 6 votes |
protected MultiBranchProject mockMbp(String credentialId,User user, String credentialDomainName){ MultiBranchProject mbp = mock(MultiBranchProject.class); when(mbp.getName()).thenReturn("PR-demo"); when(mbp.getParent()).thenReturn(j.jenkins); GitHubSCMSource scmSource = mock(GitHubSCMSource.class); when(scmSource.getApiUri()).thenReturn(githubApiUrl); when(scmSource.getCredentialsId()).thenReturn(credentialId); when(scmSource.getRepoOwner()).thenReturn("cloudbeers"); when(scmSource.getRepository()).thenReturn("PR-demo"); when(mbp.getSCMSources()).thenReturn(Lists.<SCMSource>newArrayList(scmSource)); BlueOceanCredentialsProvider.FolderPropertyImpl folderProperty = mock(BlueOceanCredentialsProvider.FolderPropertyImpl.class); DescribableList<AbstractFolderProperty<?>,AbstractFolderPropertyDescriptor> mbpProperties = new DescribableList<AbstractFolderProperty<?>,AbstractFolderPropertyDescriptor>(mbp); mbpProperties.add(new BlueOceanCredentialsProvider.FolderPropertyImpl( user.getId(), credentialId, BlueOceanCredentialsProvider.createDomain(githubApiUrl) )); Domain domain = mock(Domain.class); when(domain.getName()).thenReturn(credentialDomainName); when(folderProperty.getDomain()).thenReturn(domain); when(mbp.getProperties()).thenReturn(mbpProperties); return mbp; }
Example 4
Source File: RepairnatorPostBuild.java From repairnator with MIT License | 6 votes |
public void createGlobalEnvironmentVariables(String key, String value){ Jenkins instance = Jenkins.getInstance(); DescribableList<NodeProperty<?>, NodePropertyDescriptor> globalNodeProperties = instance.getGlobalNodeProperties(); List<EnvironmentVariablesNodeProperty> envVarsNodePropertyList = globalNodeProperties.getAll(EnvironmentVariablesNodeProperty.class); EnvironmentVariablesNodeProperty newEnvVarsNodeProperty = null; EnvVars envVars = null; if ( envVarsNodePropertyList == null || envVarsNodePropertyList.size() == 0 ) { newEnvVarsNodeProperty = new hudson.slaves.EnvironmentVariablesNodeProperty(); globalNodeProperties.add(newEnvVarsNodeProperty); envVars = newEnvVarsNodeProperty.getEnvVars(); } else { envVars = envVarsNodePropertyList.get(0).getEnvVars(); } envVars.put(key, value); try { instance.save(); } catch(Exception e) { System.out.println("Failed to create env variable"); } }
Example 5
Source File: AbstractKubernetesPipelineTest.java From kubernetes-plugin with Apache License 2.0 | 6 votes |
@Before public void configureCloud() throws Exception { cloud = setupCloud(this, name); createSecret(cloud.connect(), cloud.getNamespace()); cloud.getTemplates().clear(); cloud.addTemplate(buildBusyboxTemplate("busybox")); setupHost(); r.jenkins.clouds.add(cloud); DescribableList<NodeProperty<?>, NodePropertyDescriptor> list = r.jenkins.getGlobalNodeProperties(); EnvironmentVariablesNodeProperty newEnvVarsNodeProperty = new hudson.slaves.EnvironmentVariablesNodeProperty(); list.add(newEnvVarsNodeProperty); EnvVars envVars = newEnvVarsNodeProperty.getEnvVars(); envVars.put("GLOBAL", "GLOBAL"); envVars.put("JAVA_HOME_X", "java-home-x"); r.jenkins.save(); }
Example 6
Source File: JenkinsConfiguratorTest.java From configuration-as-code-plugin with MIT License | 5 votes |
@Test @ConfiguredWithCode("ConfigureLabels.yml") public void shouldExportLabelAtoms() throws Exception { DescribableList properties = Jenkins.get().getLabelAtom("label1").getProperties(); properties.add(new TestProperty(1)); final ByteArrayOutputStream out = new ByteArrayOutputStream(); ConfigurationAsCode.get().export(out); final String exported = out.toString(); String content = FileUtils.readFileToString(new File(getClass().getResource("ExpectedLabelsConfiguration.yml").toURI()), "UTF-8"); assertThat(exported, containsString(content)); }