How to reset the Xray <> Artifactory connection without losing scan results

Patrick Russell
2020-02-03 23:44


Sometimes you need to reset the Artifactory Xray connection. Some examples include resetting the Admin credentials, changing the Artifactory URL, or resetting the token Xray uses. Here's how to do it without wiping the Artifactory scan history.

Affected Versions

Xray 1.12 and above – Artifactory 5.10 and above 


If done properly, these steps will not delete the index status of the artifacts, as long as the original Artifactory is still available. 

Xray uses a Mongo Database to manage the server's configurations. This database contains a single entry which is used to connect to Artifactory. This entry has the Artifactory URL, Admin credentials, and Binary Manager ID

Preserving the Binary Manager ID is key to keeping the scan results intact. As this procedure involves making direct database changes, please take a backup of the MongoDB before proceeding:
 mongodump –archive=mongodump.archive –db xray 

Steps to remove an Artifactory “binary manager” from Xray:

1. Get onto the mongo. The CLI is pre-installed when MongoDB is installed, or perform a "docker exec" into the Mongo container.

Note: In later releases of Xray the MongoDB password is randomized and is no longer "password." There should be a "MongoDB_Admin_pass.txt" file located either in /root or in the user's home folder.

[RPM/Debian install example command]

 mongo -u xray --authenticationDatabase xray --authenticationMechanism SCRAM-SHA-1 -p password

2. Use the Xray database

 use xray

3. Find the binary managers


4. Delete the binary manager – Note the name used here!

 db.binary_managers.remove({"bin_mgr_id" : "art-gcp"})


If the Artifactory to reset was an authentication provider, do steps 5, 6, and 7:
You'll see this error when trying step 8:

[2019/01/25 21:09:22 UTC] [EROR] ( Failed to create xray config for Artifactory: failed to import binary manager internal admin user 'art-gcp_xray' to Access

Do these extra MongoDB steps:

5. Get the Access provider configuration:


6. Remove the "accessConfig" configuration

db.configuration.remove({ "config_id" : "accessConfig"})

7. Restart Xray

8. Re-add Artifactory to Xray through the UI as if this is the first connection. Change or update any info that needs to be updated, with one exception.

You need to use the same name for Artifactory as before. This string should exactly match the "bin_mgr_id" field that was in the MongoDB.

Xray uses the bin_mgr_id to store scan results tied to a specific Artifactory. Since the only thing that is deleted is the connection URL entry, the scan results are preserved.

After following these steps, Artifactory and Xray should reconnect seamlessly and begin functioning again. If not, you need to restore the original MongoDB configuration:

[RPM / Debian example – Only do if something goes wrong]
mongorestore -u xray -p password –authenticationDatabase xray –archive=mongodump.archive –db xray -v