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.
-
In Artifactory, go to Administration > Repositories > Layout, and then click on New.
-
Under Layout Name, you'll want to name your layout (we'll call ours here: simple-version).
-
For this case, our Artifact Path Pattern can be structured in this manner:
4. Enter the appropriate information in the following window:
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:
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:
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.
12. After deploying two jar packages, your repository should look like this:
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"
Download:
curl -uadmin:password -X GET "http://localhost:8081/artifactory/simple-local/MyProject/Package-[RELEASE].jar" -o ./Downloads/myapp.jar