Add API endpoint to retrieve Conan package revisions

What does this MR do and why?

Add API endpoint to retrieve Conan recipe revisions, this allows to run conan cli command: conan search testPackage2/1.0@group1+conan-test/stable#1883c9f810f2d6e5b59d5285c7141970:133a1f2158ff2cf69739f316ec21143785be54c7 --revisions

Endpoint:

GET /projects/:id/packages/conan/v2/conans/:package_name/:package_version/:package_username/:package_channel/revisions

Changelog: added

References

How to set up and validate locally

  1. Switch the conan_package_revisions_support feature flag on.

    For GDK, open rails console (docs):

    gdk rails console

    Enable the feature flag:

    # Enable
    Feature.enable(:conan_package_revisions_support)
    
    # Verify
    Feature.enabled?(:conan_package_revisions_support)
  2. Create and upload multiple package revisions

    Use your example to create two package revisions:

    # Create a file to upload
    echo "info" > "conaninfo.txt"
    
    # Get Conan auth token first
    curl --request GET \
        --url "http://localhost:3000/api/v4/projects/YOUR_PROJECT_ID/packages/conan/v1/users/authenticate" \
        --header "Authorization: Basic $(echo -n '<YOUR_USERNAME>:<YOUR_TOKEN>' | base64)" \
        --header "Accept: text/plain"
    
    # Upload the file with different package revisions
    curl --request PUT \
        --upload-file conaninfo.txt \
        --url 'http://localhost:3000/api/v4/projects/<project_id>/packages/conan/v2/conans/packagerevisions/1.0.0/user/stable/revisions/123456789012345678901234567890ab/packages/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/revisions/3bdd2d8c8e76c876ebd1ac0469a4e72c/files/conaninfo.txt' \
        --header 'Authorization: Bearer <YOUR-CONAN-JWT-TOKEN>'
    
    curl --request PUT \
        --upload-file  conaninfo.txt \
        --url 'http://localhost:3000/api/v4/projects/<project_id>/packages/conan/v2/conans/packagerevisions/1.0.0/user/stable/revisions/123456789012345678901234567890ab/packages/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/revisions/2bfb52659449d84ed11356c353bfbe86/files/conaninfo.txt' \
        --header 'Authorization: Bearer <YOUR-CONAN-JWT-TOKEN>'
  3. Test with conan search --revisions

    Now search for all revisions of your package revisions:

    conan search packagerevisions/1.0.0@user/stable#123456789012345678901234567890ab:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 --revisions -r gitlab-local-instance

    The output should show both revisions with their timestamps, similar to:

    Revisions for 'None' at remote 'gitlab-local-instance':
        2bfb52659449d84ed11356c353bfbe86 (2024-XX-XX XX:XX:XX UTC)
        3bdd2d8c8e76c876ebd1ac0469a4e72c (2024-XX-XX XX:XX:XX UTC)

    Note: If you do not have revisions on you will get the following error:

    ERROR: The client doesn't have the revisions feature enabled. Enable this feature setting to '1' the environment variable 'CONAN_REVISIONS_ENABLED' or the config value 'general.revisions_enabled' in your conan.conf file

    Make sure you have revisions switched on for Conan 1 by running:

    export CONAN_REVISIONS_ENABLED=1
  4. Verify with direct API call

    You can also verify the API endpoint directly using the same token from step 2:

    # Test the revisions endpoint
    curl --request GET \
        --url "http://localhost:3000/api/v4/projects/<project_id>/packages/conan/v2/conans/packagerevisions/1.0.0/user/stable/revisions/123456789012345678901234567890ab/packages/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/revisions/" \
        --header "Authorization: Bearer YOUR_CONAN_TOKEN"

    The response should match your new API format:

    {
        "packageReference": "packagerevisions/1.0.0@user/stable#123456789012345678901234567890ab:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9",
        "revisions": [
            {
            "revision": "2bfb52659449d84ed11356c353bfbe86",
            "time": "2025-04-26T00:31:46.750Z"
            },
            {
            "revision": "3bdd2d8c8e76c876ebd1ac0469a4e72c",
            "time": "2025-04-26T00:30:43.337Z"
            }
        ]
    }

/cc @oceane_scania

Related to #519741 (closed)

Edited by 🤖 GitLab Bot 🤖

Merge request reports

Loading