Search in sources :

Example 1 with Npmrc

use of jenkins.plugins.nodejs.configfiles.Npmrc 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 = new MockBuild(j.createFreeStyleProject(), folder.newFolder());
    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) Config(org.jenkinsci.lib.configprovider.model.Config) NPMConfig(jenkins.plugins.nodejs.configfiles.NPMConfig) StandardUsernameCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials) FreeStyleBuild(hudson.model.FreeStyleBuild) ConfigFile(org.jenkinsci.lib.configprovider.model.ConfigFile) File(java.io.File) Test(org.junit.Test)

Aggregations

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