How to create simple versioning custom layout in Artifactory

How to create simple versioning custom layout in Artifactory

Tatarao Vana

This tutorial will show you how to set up a simple custom layout, as well as how to use a cURL command to download the latest version of an artifact from a repository without specifying its version number.

  1. In Artifactory, go to Administration > Repositories > Layout, and then click on New.

  2. Under Layout Name, you'll want to name your layout (we'll call ours here: simple-version).

  3. For this case, our Artifact Path Pattern can be structured in this manner:
    User-added image

    4. Enter the appropriate information in the following window:
    User-added image

    5. In the Test Artifacts Path Resolution window, enter an example from Step #3, then click the Test button. Thereafter, your window should look like this:
    User-added image 

    6. Click the Save button

    7. Now, you'll need to create a generic repository by going to Administration > Repositories > Local, and then clicking on New and selecting Generic as a package type:
    User-added image

    8. In this example, we'll name our repository: simple-local.

    9. From the Repository Layout dropdown menu, select the recently-created custom layout: simple-version.

    10. Click the Save & Finish button.

    11. For testing purposes, we'll create two files (Package-1.0.jar and Package -1.1.jar) and deploy them to the simple-local repository in a folder we'll call MyProject, which we'll create during the deployment by typing it in the Target Path window.
    User-added image

    12. After deploying two jar packages, your repository should look like this:
    User-added image

    13. Now we'll use a cURL command with –I to see whether we can obtain a head request from the latest version. Thereafter, we'll use an –o to download that version.

    Head Request:
    curl -I -uadmin:password -X GET "http://localhost:8081/artifactory/simple-local/MyProject/Package-[RELEASE].jar"
    User-added image

    curl -uadmin:password -X GET "http://localhost:8081/artifactory/simple-local/MyProject/Package-[RELEASE].jar" -o ./Downloads/myapp.jar

    User-added image