How to create simple versioning custom layout in Artifactory

In this tutorial, you will learn to set up a simple custom layout. You will also need to download the latest version of the artifact without specifying the version from the repository using cURL command. 

1. First, we will need to create a simple layout. In Artifactory, got to [Admin] —> [Repositories] —> [Layout], then click on “New”

 

2. Give a name to “Layout Name”, in our case it will be called “simple-version”

 

3. “Artifact Path Pattern” in this particular case can be structured in this form:

Example:

4. Fill out the information in the following windows shown below:

5. In “Test Artifacts Path Resolution” window enter an example from the step 3,  then hit on “Test” button, your window should look like this:

6. Hit on “Save” button.

7. Now, we will need to create a Generic Repository. Go to  [Admin] » [Repositories] » [Local], then click on  “New” and choose “Generic” as a package type:

8. In this example, we are going to name this repository “simple-local”

9. From “Repository Layout” dropdown list we will choose our recently created custom layout “simple-version”

10. Leave the rest of the windows as is, and then hit “ Save & Finish” button.

11. For testing purposes, we will create two files, and deploy them into MyProject folder inside our “simple-local” repository.

 

        Please Note: We will create MyProject folder during the deployment by typing it in “Target Path” window.

         a. Package-1.0.jar

         b. Package-1.1.jar

12. After deploying two jar packages, your repository should look like this:

13. Now we will use curl command with “ –I “ to see whether we can get a Head Request from the latest version, and then we will use “ –o “ to download that version.

Head Request:

curl -I -uadmin:password -X GET “http://localhost:8081/artifactory/simple-local/MyProject/Package-[RELEASE].jar”

Download:

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

That’s it!

We hope this tutorial will give you a better understanding of Artifactory layouts.