How to upload complete folder structure to Artifactory repo to a new folder and keep he folder name as it is? - artifactory

I'm new to automation and Tried uploading entire folder structure to Artifactory repo with parent folder and child folders
structure is as below
test1 folder contains sub-folder: new_ref and it also contains sub-folder>>v1, new_data1 and it also contains sub-folder>>v1, v1 and it also contains sub-folder>>bl, memo
Tried using both --flat=true and false option:
jfrog.exe rt u --flat=false "F:/main/test1/" mr-local-generic/new_data/
On Artifactory its required to create folder name "new_data" and under that it should upload below folders with their respective child folders intact: new_ref, new_data1, v1, memo
But it creates folder name as new_data/F:/main/test1/ , how to resolve this any help is much appreciated.

--flat=false keeps the system hierarchy. If you wish to upload without the path prefix, you have the following options:
Run the upload command from the directory you wish to upload from, and use relative path with --flat=false:
cd /d F:\main\test1
jfrog.exe rt u --flat=false "./" mr-local-generic/new_data/
Use Placeholders:
jfrog.exe rt u "F:/main/test1/(*)" mr-local-generic/new_data/{1}
To apply the source path pattern for directories as well as files, add the include-dirs flag.
For example:
jfrog.exe rt u --include-dirs=true "F:/main/test1/(*)" mr-local-generic/new_data/{1}

Related

How to Upload Multiple Artifacts to artifactory along with their folder structure using Jfrog CLI

I need to upload all the artifacts generated as part of the build to artifactory based on its folder structure.
Here folder structure is nothing but group id, version and artifact id was mentioned at pom level in case of all the dependencies.
So the expectation is how to mention that folder structure in "jfrog rt upload" CLI command?
Because the folder structure will change for every artifact.
jfrog rt upload --flat=false "${dynamic folder structure}/*" p2-release-local/
As per our expectation artifacts should go like this,
http://<artifactorylink>/<group id>/<artifac id>/<version>/<.jar>
http://<artifactorylink>/<group id>/<artifac id>/<version>/<.pom>
NOTE: Am using freestyle job in jenkins, so i cannot use the jfrog plugin to do this for me. And the plugins which are availalbe in freestyle job also will upload some artifacts even we need to provide group and artifact id for it. so it doesn't seems to be helping.
Please let me know how to could accomplish this expectation or if there is anyother way i could upload these artifacts to JFROG along with folder structure.
If you want to upload a folder and files in it using JFrog CLI, you may visit this confluence page for the complete details.
In short, you may use the below command.
jfrog rt u "root/test/(*)" p2-release-local/test/{1}
To apply the source path pattern for directories as well as files, add the include-dirs flag.
jfrog rt u --include-dirs=true "root/test/(*)" p2-release-local/folder/{1}

UNIX: how to zip a folder that contains more folders w/o including any of the folder paths

I' m trying to zip a folder that contains some .json files plus subfolders with more .json files. I need to zip the parent folder with everything included without containing any of the parent or subfolders paths. Is there any way I can do this?
Thank you
EDIT:
I want this:
pending_provider/722c9cb2-268b-4e4a-9000-f7f65e586011-version/1d296136-ac87-424e-89c4-682a63c7b853.json (deflated 68%)
But not this:
pending_provider/722c9cb2-268b-4e4a-9000-f7f65e586011-version/ (stored 0%)
I want to avoid the "stor" compression type which only saves the folder path. I want only the "defN"
So the -j doesn't help me a lot
Thanks
If you don't want any paths at all you could use the -j option. Below is the man page entry for the option.
-j
--junk-paths
Store just the name of a saved file (junk the path), and do not store
directory names. By default, zip will store the full path (relative to
the current directory).
If you just want to exclude directories
-D
--no-dir-entries
Do not create entries in the zip archive for directories.

Symlink working but is showing the directory one level up for some reason

I have a directory that contains media that I am trying to setup a basic symbolic link to - the directory is a mounted storage on a digital ocean droplet in the following directory /mnt/storage/media/all
this contains directories as shown below:
0118
0119
0218 and so on.......
I am trying to make a symlink from my unix terminal as follows :
$ root#server1:/var/www/abcd/public ln -s /mnt/storage/media/all
So if I cd into the public directory above I would expect to see the directories 0118, 0119, 0218 and so on... however when I cd into this directory I see the directory all and within this directories are the 0118, 0119, 0218 subdirectories.
How do I change the symbolic link so I see the directories 0118, 0119, 0218 etc.. and not the all directory (which contains those same sub directories)
Try giving a second argument for the function. Let that argument be the desired destination for the link (but it shouldn't exist prior to this).
E.g. ln -s /mnt/storage/media/all /var/www/abcd/public
In case the folder public already exists, the symlink will be created inside it.

jfrog copy directory to another directory

With the jfrog-cli I want to copy "tags/$version" to "released/$version"
$version has subdirectories that I need to keep in the respective format.
I tried :
jfrog rt cp --flat=false repo/tags/$version/* repo/released/
What I get is :
repo/released/tags/$version
Can anyone help?
Artifactory cp/mv is BIZARRE... it does not work like a regular file system move or copy command.
The following moves (within the same repository) everything including subfolders from test/example/libraries/1.0.0 to test/example/libraries/2.0.0 .
jfrog rt mv release-local/test/example/libraries/1.0.0 release-local/2.0.0 --user ${userid} --password ${userpwd} --url https://artifactory
Before
/test
/example
/libraries
/1.0.0
file1.dll
/folder1
file2.dll
After
/test
/example
/libraries
/2.0.0
file1.dll
/folder1
file2.dll
The command appears to take the last element of the path of the target and replace it with the entire path of the source repository less the last element of the path... basically it is like a file rename that includes the path as part of the rename. Note that you do not have to use the recursive flag or the flat flag for it.
In the latest release of JFrog CLI (version 1.23.1) the command to copy files from one repository to another should be similar to what you have.
For example, if I want to copy all versions from a repository libs-snapshot-local/ and path org/jfrog/test/ to a repository called generic-local I can execute the command
jfrog rt cp libs-snapshot-local/org/jfrog/test/ generic-local/
By default, it will recursively copy all items of libs-snapshot-local/org/jfrog/test/ to their new location in generic-local

How to archive the content of a folder recursively as artifacts on Jenkins?

My jenkins job creates a temporary subfolder, say "mydir", within the workspace that I then want to archive using the postbuild step "Archive artifacts".
I'm using the following command:
mydir/**/*
It works well but the archive will always contains mydir as the root of the artifacts whereas I would like to have the contents of this folder only.
How to do this?
You can use dir() to archive the artifact from inside the desired directory:
stage('Archive') {
steps {
dir('mydir') {
archiveArtifacts artifacts: '**'
}
}
}
https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#dir-change-current-directory
What I've done in this cases is create a compressed file (tar or zip) of the directory I'm interested, and then artifact it instead artifact the whole directory. If your slave is running in linux you can do as follow:
tar -czvf name-of-archive.tar.gz /path/of/build/directory
Then artifact name-of-archive.tar.gz
To archive your entire folder in jenkins.
In your case let us say. If you want to archive complete "mydir" folder
**/my_dir/**
That is one way. If you have other folders with the same name. Then you can provide proper parent directory as well.
You can check the option "Flatten directories" on the plugin's settings

Resources