I’m trying to create npm proxy repository via script API including authentication.
Looking at The source code, createNpmProxy function doesn’t seem to support it:
@Nonnull
Repository createNpmHosted(final String name,
final String blobStoreName = BlobStoreManager.DEFAULT_BLOBSTORE_NAME,
final boolean strictContentTypeValidation = true,
final WritePolicy writePolicy = WritePolicy.ALLOW)
{
createRepository(createHosted(name, 'npm-hosted', blobStoreName, writePolicy, strictContentTypeValidation))
}
@Nonnull
Repository createNpmProxy(final String name,
final String remoteUrl,
final String blobStoreName = BlobStoreManager.DEFAULT_BLOBSTORE_NAME,
final boolean strictContentTypeValidation = true)
{
createRepository(createProxy(name, 'npm-proxy', remoteUrl, blobStoreName, strictContentTypeValidation))
}
@Nonnull
Repository createNpmGroup(final String name,
final List<String> members,
Is there a way to use some low level method like createProxy or createRepository in order to create npm repository with authentication?
rseddon
(Rich Seddon)
November 5, 2019, 2:53pm
2
Here’s an example of how to add credentials to a proxy repository.
import org.sonatype.nexus.blobstore.api.BlobStoreManager
import org.sonatype.nexus.repository.storage.WritePolicy
import org.sonatype.nexus.repository.maven.VersionPolicy
import org.sonatype.nexus.repository.maven.LayoutPolicy
repository.createMavenProxy('proxy1', 'https://some.remote.com/', 'default', true, VersionPolicy.RELEASE, LayoutPolicy.PERMISSIVE)
def creds = [:].withDefault { 0 }
creds.put('type','username')
creds.put('username','test')
creds.put('password','test123')
repository.getRepositoryManager().get('proxy1').getConfiguration().getAttributes().'httpclient'.'authentication' = creds