I have a jFrog Artifactory local installation that is shipped with some other software that uses it heavily and I am forced to use it.
Since I don’t have the time to connect my GitLab CI to Artifactory (not sure if even possible with the free version), I decided to download my CI artifacts and then add them manually to a local Artifactory generic repo.
Initially I tried the Deploy button but neither single nor multiple upload seems to work as expected:
- Single file upload requires a lot of work (target path needs to be written manually) and for some file (e.g. DLLs and even some
LICENSE
files (without extension)) it states that the file is undefined whatever that means. Directories do not seem to work at all (which would make sense I guess) - Multiple files upload works in terms of being able to upload multiple files. However, again I need to specify the target path manually. Also some files also give me the undefined nonsense.
I tried the curl
that is given to the user when clicking on Set Me Up in the Deploy section, e.g.
curl -u admin:password -T <PATH_TO_FILE> “http://127.0.0.1:8081/artifactory/Dependencies/<TARGET_FILE_PATH>”
As I have found out this is something cURL doesn’t support. I read (but might have missed something) the manpage for the tool.
So I started digging. I found (e.g. SO answer)
curl -u user:password -X PUT http://[artifactory URL]/[repository name] -T /tmp/src/archive.zip -H 'X-Explode-Archive: true'
where the directory is archived, deployed and extracted, which ensures that the underlying directory structure is preserved. However, everyone seems to forget this is a Pro feature and if you try it, you will promptly get an error from Artifactory telling you this:
"errors" : [ {
"status" : 400,
"message" : "This REST API is available only in Artifactory Pro."
} ]
}
My search lead me to the next one:
find <DIR-TO-UPLOAD> -type f -exec curl -u admin:password -T {} "http://127.0.0.1:8081/artifactory/<REPO>/"
However, perhaps because I am using Git Bash (I have read there are some issue running cURL in particular in such an environment) I get
$ find debug -type f -exec curl -u admin:password -T {} "http://127.0.0.1:8081/artifactory/Dependencies/"
find: missing argument to `-exec'
At least find
seems to work in terms of getting a list of files, e.g.
...
debug/include/spdlog/tweakme.h
debug/include/spdlog/version.h
debug/lib
debug/lib/DirectXTex.lib
debug/lib/DirectXTex.pdb
debug/lib/imgui_static.lib
debug/lib/spdlogd.lib
debug/LICENSE
debug/LICENSES_nlohmann
debug/LICENSE_argparse
debug/LICENSE_DirectXTex
debug/LICENSE_imgui
debug/LICENSE_nlohmann
debug/LICENSE_opencv
debug/LICENSE_spdlog
debug/OpenCVConfig-version.cmake
debug/OpenCVConfig.cmake
debug/setup_vars_opencv4.cmd
debug/x64
debug/x64/vc16
debug/x64/vc16/bin
debug/x64/vc16/bin/opencv_calib3d4100d.dll
debug/x64/vc16/bin/opencv_core4100d.dll
...
I am currently looking into writing a script (since I use Windows probably in Powershell) to do something similar to
#!/bin/sh
for file in /folder/path/* # Can replace with find call
do
curl -u username:password -T ${file} http://www.example.com/folder/${file}
done
cURL also supports multiple files and URLs in a single call.
But I am curious if the free version of Artifactory is really that crippled and such a trivial task is not supported without the customer having to pay up. I currently have almost 700 files (DLLs, libs, config files, LICENSE files, documentation and what not) and I certainly don’t have the willpower to manually upload each one manually.
Since I am new to Artifactory, I would also like to know if one can copy artifacts to wherever the repository Artifactory manages stores its files on the local system. Sadly, I have the feeling that would not be possible but worth asking anyways.