Search in sources :

Example 1 with NPMRegistry

use of jenkins.plugins.nodejs.configfiles.NPMRegistry in project nodejs-plugin by jenkinsci.

the class NpmrcFileSupplyTest method test_supply_npmrc_with_registry.

@Test
public void test_supply_npmrc_with_registry() throws Exception {
    StandardUsernameCredentials user = createUser("test-user-id", "myuser", "mypassword");
    NPMRegistry privateRegistry = new NPMRegistry("https://private.organization.com/", user.getId(), null);
    NPMRegistry officalRegistry = new NPMRegistry("https://registry.npmjs.org/", null, "@user1 user2");
    Config config = createSetting("mytest", "email=guest@example.com", Arrays.asList(privateRegistry, officalRegistry));
    FreeStyleBuild build = j.buildAndAssertSuccess(j.createFreeStyleProject());
    FilePath npmrcFile = ConfigFileManager.provisionConfigFile(new ConfigFile(config.id, null, true), null, build, build.getWorkspace(), j.createTaskListener(), new ArrayList<String>(1));
    assertTrue(npmrcFile.exists());
    assertTrue(npmrcFile.length() > 0);
    Npmrc npmrc = Npmrc.load(new File(npmrcFile.getRemote()));
    assertTrue("Missing setting email", npmrc.contains("email"));
    assertEquals("Unexpected value from settings email", "guest@example.com", npmrc.get("email"));
}
Also used : FilePath(hudson.FilePath) Npmrc(jenkins.plugins.nodejs.configfiles.Npmrc) NPMRegistry(jenkins.plugins.nodejs.configfiles.NPMRegistry) ConfigFile(org.jenkinsci.lib.configprovider.model.ConfigFile) NPMConfig(jenkins.plugins.nodejs.configfiles.NPMConfig) Config(org.jenkinsci.lib.configprovider.model.Config) StandardUsernameCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials) FreeStyleBuild(hudson.model.FreeStyleBuild) File(java.io.File) ConfigFile(org.jenkinsci.lib.configprovider.model.ConfigFile) Test(org.junit.Test)

Example 2 with NPMRegistry

use of jenkins.plugins.nodejs.configfiles.NPMRegistry in project nodejs-plugin by jenkinsci.

the class JCasCTest method checkConfigFile.

private void checkConfigFile(Jenkins j) {
    Config config = ConfigFiles.getByIdOrNull(j, "myconfigfile");
    assertThat(config, instanceOf(NPMConfig.class));
    NPMConfig npmConfig = (NPMConfig) config;
    assertEquals("myComment", npmConfig.comment);
    assertEquals("myContent", npmConfig.content);
    assertEquals("myConfig", npmConfig.name);
    List<NPMRegistry> registries = npmConfig.getRegistries();
    Assert.assertTrue(registries.size() == 1);
    NPMRegistry registry = registries.get(0);
    assertTrue(registry.isHasScopes());
    assertEquals("myScope", registry.getScopes());
    assertEquals("registryUrl", registry.getUrl());
}
Also used : NPMConfig(jenkins.plugins.nodejs.configfiles.NPMConfig) NPMRegistry(jenkins.plugins.nodejs.configfiles.NPMRegistry) NPMConfig(jenkins.plugins.nodejs.configfiles.NPMConfig) Config(org.jenkinsci.lib.configprovider.model.Config)

Aggregations

NPMConfig (jenkins.plugins.nodejs.configfiles.NPMConfig)2 NPMRegistry (jenkins.plugins.nodejs.configfiles.NPMRegistry)2 Config (org.jenkinsci.lib.configprovider.model.Config)2 StandardUsernameCredentials (com.cloudbees.plugins.credentials.common.StandardUsernameCredentials)1 FilePath (hudson.FilePath)1 FreeStyleBuild (hudson.model.FreeStyleBuild)1 File (java.io.File)1 Npmrc (jenkins.plugins.nodejs.configfiles.Npmrc)1 ConfigFile (org.jenkinsci.lib.configprovider.model.ConfigFile)1 Test (org.junit.Test)1