artifactoryjfrog-cliartifactory-query-langjfrog-xray

How to retrieve a list of projects from Artifactory


I need to create a series of scripts which do meaningful things across both Artifactory and X-Ray. The things I need to do requires I already have the project IDs. As a platform admin, I have access to those via the UI but I need to use them on the CLI and I don't want to hand curate a list.

I haven't found any method, be it UI, CLI or REST to return a list of all the projects. I have seen that there's an Artifactory query language but I don't think I'll get permission to query the back-end database directly.

JFrog documentation is difficult to follow but I've been reading as much as I can and it looks like there's no specific API for this.

How can I get a list of all projects returned programmatically using any of the above methods?

I haven't been able to try anything as the documentation lacks any reference to generating a list of projects. I expected there to be some single API, REST or CLI, what-have-you, but I have been unable to find one. Ideally, I'd like a list returned in some structured form like JSON, XML or CSV but just a big ole string is fine, too.


Solution

  • You can use the Get Projects List REST API to list the projects. For this you need to pass the a Bearer token. You can login to Artifactory > Administrator > User Management > Access Tokens > Create a new token

    Once you have the access token you can run the Rest call.

    curl -H "Authorization: Bearer XXXXXXXXXXXXXXX" -XGET http://ArtiURL:8082/access/api/v1/projects
    

    This should give the list of all the projects.