Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
*.iml

.DS_Store
${env.ARTIFACTORY_HOME}/etc/plugins/dummyPlugin.groovy
6 changes: 3 additions & 3 deletions migration/artifactoryMigrationHelper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ This user plugin moves only repository and artifact data and metadata. If you wi

To install this plugin:

1. Place file `artifactoryMigrationHelper.json` under the master Artifactory server `${ARTIFACTORY_HOME}/etc/plugins`
1. Place file `artifactoryMigrationHelper.json` under the master Artifactory server `${ARTIFACTORY_HOME}/var/etc/artifactory/plugins`
2. Edit `artifactoryMigrationHelper.json` file content according to your preferences/environment
3. Place file `artifactoryMigrationHelper.groovy` under the master Artifactory server `${ARTIFACTORY_HOME}/etc/plugins`
3. Place file `artifactoryMigrationHelper.groovy` under the master Artifactory server `${ARTIFACTORY_HOME}/var/etc/artifactory/plugins`
4. Request [user plugins reload](https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-ReloadPlugins)
2. Verify in the system logs that the plugin loaded correctly.

### Logging

To enable logging, add the following lines to `$ARTIFACTORY_HOME/etc/logback.xml` file. There is no need to restart Artifactory for this change to take effect:
To enable logging, add the following lines to `$ARTIFACTORY_HOME/var/etc/artifactory/logback.xml` file. There is no need to restart Artifactory for this change to take effect:

```xml
<logger name="artifactoryMigrationHelper">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ def getRemoteArtifactoryRepositories() {

def copyLocalRepositoryToRemoteArtifactory(repoKey) {
def repositoryService = ctx.beanForType(InternalRepositoryService.class)
def repoDescriptor = repositoryService.localRepoDescriptorByKey(repoKey)
//Following worked until RT 6.x
//def repoDescriptor = repositoryService.localRepoDescriptorByKey(repoKey)
//New API change in RT 7.x
def repoDescriptor = repositoryService.localOrFederatedRepoDescriptorByKey(repoKey)
def repoConfiguration = new LocalRepositoryConfigurationImpl(repoDescriptor)
createRemoteArtifactoryRepo(repoKey, repoConfiguration)
}
Expand All @@ -298,6 +301,8 @@ def createRemoteArtifactoryRepo(repoKey, repoConfiguration) {
def repoConfigurationJson = new ObjectMapper().writeValueAsString(repoConfiguration)
log.debug "Repo Configuration: $repoConfigurationJson"
repoConfigurationJson = removeNullProperties(repoConfigurationJson)
// Need to set new field "rclass: <type_of_repo>" in RT 7.x
repoConfigurationJson = setRclass(repoConfigurationJson)
log.debug "Cleaned Repo Configuration: $repoConfigurationJson"

def url = config.target + "api/repositories/$repoKey"
Expand All @@ -319,6 +324,14 @@ def createRemoteArtifactoryRepo(repoKey, repoConfiguration) {
}
}

// Need to set new field "rclass: <type_of_repo>" in RT 7.x . This field will have same value as the "type" field already in the json
def setRclass(json) {
def slurper = new JsonSlurper().parseText(json)

slurper.rclass = slurper.type
return new JsonBuilder(slurper).toPrettyString()
}

def removeNullProperties(json) {
def slurper = new JsonSlurper().parseText(json)
for (Iterator<Map.Entry> it = slurper.entrySet().iterator(); it.hasNext();) {
Expand Down