0
votes

I'm trying to write a simple Groovy script which deploys a text file into my artifactory. I read the REST API in order to understand how to write the script but I've seen so many vastly different versions online I'm confused.

I want it to be a simple groovy script using the REST API and curl.

This is what JFrog are suggesting in their website:

curl -u myUser:myP455w0rd! -X PUT "http://localhost:8081/artifactory/my-repository/my/new/artifact/directory/file.txt" -T Desktop/myNewFile.txt

And it might work perfectly but I don't understand each part here, and I don't know if I can simply integrate this into a groovy script as is or some adjustments are needed.

I'm a beginner in this field and I would love any help! Thanks in advance

1
I've seen it, it dosen't work or at least it dosen't work for me. plus it's waaaay too complicated and extensive. but thank you very muchMichael Segal

1 Answers

0
votes

As you are using the '-T' flag it is not required also to use the '-X PUT'. Also, the use of '-T' allows you to not specify the file name on the destination so for example, your path will be "http://localhost:8081/artifactory/my-repository/my/new/artifact/directory/' and the file name will be the same as it is on the origin.

The full command will look like that:

curl -u user:password -T Desktop/myNewFile.txt "http://localhost:8081/artifactory/my-repository/my/new/artifact/directory/"

Now just to be on the safe side, you are going to have the file name and path to file on the destination as variables right?

The -T flag should only be used for uploading files so don't take it as obvious that you can replace all '-X PUT' with '-T' but for this specific case of uploading a file, it is possible.