Skip to content

Instantly share code, notes, and snippets.

@sboardwell
Last active August 23, 2019 13:23
Embed
What would you like to do?
nexus-repo-configmap.yaml
kind: ConfigMap
apiVersion: v1
metadata:
name: nexus-custom-repo-files
namespace: jx
labels:
app: nexus-custom-repo-files
data:
redshift-maven-repository.json: |
{
"name": "redshift-maven-repository",
"type": "groovy",
"content": "def name='redshift-maven-repository'\ndef url='https://s3.amazonaws.com/redshift-maven-repository/release/'\nif(!repository.getRepositoryManager().exists(name)) {\n repository.createMavenProxy(name, url)\n}\ndef config = repository.getRepositoryManager().get(name).configuration.copy()\nconfig.attributes['proxy']['contentMaxAge'] = -1\nrepository.repositoryManager.update(config)\n"
}
apache-org-snapshots.json: |
{
"name": "apache-org-snapshots",
"type": "groovy",
"content": "def name='apache-org-snapshots'\ndef url='https://repository.apache.org/content/repositories/snapshots/'\nif(!repository.getRepositoryManager().exists(name)) { repository.createMavenProxy(name, url, 'default', true, org.sonatype.nexus.repository.maven.VersionPolicy.SNAPSHOT, org.sonatype.nexus.repository.maven.LayoutPolicy.STRICT) }"
}
my-protected-repo.json: |
{
"name": "my-protected-repo",
"type": "groovy",
"content": "def name='my-protected-repo'\ndef url='https://acme.com/repository/my-protected-repo/'\nif(!repository.getRepositoryManager().exists(name)) {\n repository.createMavenProxy(name, url, 'default', true, org.sonatype.nexus.repository.maven.VersionPolicy.RELEASE, org.sonatype.nexus.repository.maven.LayoutPolicy.STRICT)\n}\ndef config = repository.getRepositoryManager().get(name).configuration.copy()\nconfig.attributes['proxy']['contentMaxAge'] = -1\nconfig.attributes['httpclient']['authentication'] = ['type': 'username', 'username': 'my-user', 'password': 'myP@ssW0rd','ntlmHost': '','ntlmDomain': '']\nrepository.repositoryManager.update(config)\n"
}
maven-group.json: |
{
"name": "maven-group",
"type": "groovy",
"content": "def updateGroup(def name, def members) {\n if (!repository.getRepositoryManager().exists(name)) {\n repository.createMavenGroup(name, members)\n }\n def mgConfig = repository.getRepositoryManager().get(name).configuration.copy()\n mgConfig.attributes['group']['memberNames'] = members\n repository.repositoryManager.update(mgConfig)\n}\nupdateGroup('maven-group',['maven-public', 'maven-central', 'maven-releases', 'spring-milestone', 'spring-release', 'jitpack', 'jenkins-release', 'maven-jenkinsci', 'jenkins-public', 'plugins-gradle', 'my-protected-repo'])\nupdateGroup('maven-group-snapshots',['maven-snapshots', 'apache-org-snapshots', 'spring-io-libs-snapshot', 'oss-sonatype-snapshots'])\n"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment