Comments (2)
you can use the following groovy scripts (they must be optimized to be just one, but that's a good start):
- hosted repository
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.config.Configuration
parsed_args = new JsonSlurper().parseText(args)
repositoryManager = repository.repositoryManager
existingRepository = repositoryManager.get(parsed_args.name)
if (existingRepository != null) {
newConfig = existingRepository.configuration.copy()
newConfig.attributes['storage']['writePolicy'] = parsed_args.write_policy.toUpperCase()
newConfig.attributes['storage']['strictContentTypeValidation'] = Boolean.valueOf(parsed_args.strict_content_validation)
repositoryManager.update(newConfig)
} else {
configuration = new Configuration(
repositoryName: parsed_args.name,
recipeName: 'composer-hosted',
online: true,
attributes: [
storage: [
writePolicy: parsed_args.write_policy.toUpperCase(),
blobStoreName: parsed_args.blob_store,
strictContentTypeValidation: Boolean.valueOf(parsed_args.strict_content_validation)
]
]
)
repositoryManager.create(configuration)
}
- proxy
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.config.Configuration
parsed_args = new JsonSlurper().parseText(args)
repositoryManager = repository.repositoryManager
authentication = parsed_args.remote_username == null ? null : [
type: 'username',
username: parsed_args.remote_username,
password: parsed_args.remote_password
]
existingRepository = repositoryManager.get(parsed_args.name)
if (existingRepository != null) {
newConfig = existingRepository.configuration.copy()
newConfig.attributes['proxy']['remoteUrl'] = parsed_args.remote_url
newConfig.attributes['httpclient']['authentication'] = authentication
newConfig.attributes['storage']['strictContentTypeValidation'] = Boolean.valueOf(parsed_args.strict_content_validation)
repositoryManager.update(newConfig)
} else {
configuration = new Configuration(
repositoryName: parsed_args.name,
recipeName: 'composer-proxy',
online: true,
attributes: [
proxy : [
remoteUrl: parsed_args.remote_url,
contentMaxAge: parsed_args.get('content_max_age', -1),
metadataMaxAge: parsed_args.get('metadata_max_age', 1440.0)
],
httpclient: [
blocked: false,
autoBlock: true,
authentication: authentication,
connection: [
useTrustStore: false
]
],
storage: [
blobStoreName: parsed_args.blob_store,
strictContentTypeValidation: Boolean.valueOf(parsed_args.strict_content_validation)
],
negativeCache: [
enabled: parsed_args.get("negative_cache_enabled", true),
timeToLive: parsed_args.get("negative_cache_ttl", 1440.0)
]
]
)
repositoryManager.create(configuration)
}
- group
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.config.Configuration
parsed_args = new JsonSlurper().parseText(args)
repositoryManager = repository.repositoryManager
existingRepository = repositoryManager.get(parsed_args.name)
if (existingRepository != null) {
newConfig = existingRepository.configuration.copy()
newConfig.attributes['group']['memberNames'] = parsed_args.member_repos
newConfig.attributes['storage']['strictContentTypeValidation'] = Boolean.valueOf(parsed_args.strict_content_validation)
repositoryManager.update(newConfig)
} else {
configuration = new Configuration(
repositoryName: parsed_args.name,
recipeName: 'composer-group',
online: true,
attributes: [
group : [
memberNames: parsed_args.member_repos
],
storage: [
blobStoreName: parsed_args.blob_store,
strictContentTypeValidation: Boolean.valueOf(parsed_args.strict_content_validation)
]
]
)
repositoryManager.create(configuration)
}
here is the curl for adding, for example, the hosted repo:
curl -X POST -H "Content-Type: text/plain" -d "{ \"name\": \"composer-hosted\", \"write_policy\": \"allow_once\", \"strict_content_validation\": false, \"blob_store\": \"default\"}" -u admin:admin123 http://localhost:8081/service/rest/v1/script/createrepo_composerhosted/run
from nexus-repository-composer.
Since this is a community plugin so it's not supported by the RepositoryAPI. But I think you could do something similar to sonatype-nexus-community/nexus-repository-apt#66 (comment), which is also a community plugin.
from nexus-repository-composer.
Related Issues (20)
- Missing source with one package from packagist.org.
- In Composer Group hosted composer packages that were published before update are not available via v2 api HOT 1
- docker container cannot run properly, ssl connection error occurred in update
- E401 errors when publishing with scoped :_auth
- Does nexus supports arm64
- Packages do not appear in any search HOT 6
- Nexus and composer integration - failing authentication step
- composer install --prefer-source not working HOT 1
- composer redirect issue
- Composer repository no longer updates composer2 JSON files for new versions in case if redeploys are not allowed HOT 1
- Cleanup policy for composer repositories does not find any packages to remove HOT 1
- Index rebuild won't finish successfully HOT 6
- Plugin not installing on Nexus 3.51 HOT 3
- Nexus fails starting with java.lang.IllegalStateException: Missing recipe: composer-proxy after upgrading to v3.53 (Docker based) HOT 7
- An error occurred loading data. Request failed with status code 500
- package meta data - version_normalized
- Repository Cleanup , S3 storage
- External repo returns 400: Invalid Request resulting in caching 0 byte artifacts HOT 2
- Exception (com.google.inject.CreationException) while activating nexus-repository-composer for Nexus v3.62.0-01 HOT 1
- Cleanup Policy Preview is not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nexus-repository-composer.