Get list of all children from a repo in Jfrog though api - jfrog-cli

Is there a way through api, to get list of all the folders or children of a node in JFROG artifactory tool . For example I have following structure under a node Node N
> A
> B
> C
is there a way if I ask all the children of node N I would get [A,B,C].

You can use the search command to list all files matched to the input pattern:
jfrog rt s <search pattern>
jfrog rt s <repo>/<path to node N>/
# To show only direct children:
jfrog rt s <repo>/<path to node N>/ --recursive=false
More information can be found in the documentation.

Yes you can retrieve the children using api
Example:
https://Jfrog.example.com/artifactory/api/storage/examplerepo/examplefolder/
If not anonymous you may need to pass the credntials or token along with the request

Related

how to validate the Azure CLI or az command before execute?

Looking for a way to validate the AZ command result before the actual implementation.
Below is the command I want to test, The requirement is that, i need to validate the result before applying the command. I know this is possible in ARM template deployment, but is it not allowed in AzureCLI ?
az monitor metrics alert condition create --aggregation {Average, Count, Maximum, Minimum, Total}
--metric
--op {Equals, GreaterOrLessThan, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, NotEquals}
--type {dynamic, static}
[--dimension]
[--namespace]
[--num-periods]
[--num-violations]
[--sensitivity {High, Low, Medium}]
[--since]
[--skip-metric-validation {false, true}]
[--subscription]
[--threshold]
AFAIK, Whatif is only available for az group or subscription deployment and it cant be used in a single line or direct mode az commands.
There is debug option in other az cmd but i don't think it will serve your purpose.
For more information please refer the below links:
ARM template deployment what-if operation| MS DOC
Az deployment|MS DOC
Az CLI reference| MS DOC

How set feature by id via Data Hub CLI?

Could you please help me to find proper command in HERE CLI that to request of feature by id ?
I am trying it now, but it's return all features:
here xyz show MY_SPACE_ID --feature MY_SPACE_ID,MY_FEATURE_ID
the proper command is:
here xyz show MY_SPACE_ID -s "f.id=MY_FEATURE_ID" -r

name of repository being appended to URL

Im trying to upload a file to my repo using the following command in JFrog CLI:
jfrog rt u ".\Builds\mybuild.apk" buildrepo-generic-local --url=https://buildrepo-generic-local.artifactory.mycompany.com/artifactory/buildrepo-generic-local/Gitlab/mybuild/client/Test --user=myuser --password=mypass --build-name BuildName --build-number=0000
but it appends the name of the repo on the url so it actually gets uploaded to:
https://buildrepo-generic-local.artifactory.mycompany.com/artifactory/buildrepo-generic-local/Gitlab/mybuild/client/Test/buildrepo-generic-local/mybuild.apk
and not where i want it which is:
https://buildrepo-generic-local.artifactory.mycompany.com/artifactory/buildrepo-generic-local/Gitlab/mybuild/client/Test/mybuild.apk
Im new so its probably me doing something wrong, anyone help here?
The second argument of the upload command is the destination path in Artifactory. In your case that is:
buildrepo-generic-local/Gitlab/mybuild/client/Test/mybuild.apk
The url flag is the url of your Artifactory without path:
--url=https://buildrepo-generic-local.artifactory.mycompany.com/artifactory/
For more details, see the JFrog CLI documentation.

Get size of specific repository in Nexus 3

How can I get a size of specific repository in Nexus 3?
For example, Artifactory shows the repository "size on disk" via UI.
Does Nexus have something similar? If not - how can I get this information by script?
You can use admin task with groovy script nx-blob-repo-space-report.groovy from https://issues.sonatype.org/browse/NEXUS-14837 - for me turned out too slow
Or you can get it from database:
login with user-owner nexus installation on nexus server (e.g.
nexus)
go to application directory (e.g. /opt/nexus):
$ cd /opt/nexus
run java orient console:
$ java -jar ./lib/support/nexus-orient-console.jar
connect to local database (e.g. /opt/sonatype-work/nexus3/db/component):
> CONNECT PLOCAL:/opt/sonatype-work/nexus3/db/component admin admin
find out repository row id in #RID column by repository_name value:
> select * from bucket limit 50;
get sum for all assets with repo row id found in the previous step:
> select sum(size) from asset where bucket = #15:9;
result should be like (apparently in bytes):
+----+------------+
|# |sum |
+----+------------+
|0 |224981921470|
+----+------------+
nexus database connection steps took from https://support.sonatype.com/hc/en-us/articles/115002930827-Accessing-the-OrientDB-Console
another useful queries
summary size by repository name (instead 5 and 6 steps):
> select sum(size) from asset where bucket.repository_name = 'releases';
top 10 repositories by size:
> select bucket.repository_name as repository,sum(size) as bytes from asset group by bucket.repository_name order by bytes desc limit 10;
Assign each repository to its own Blob Store.
You can refer below GitHub project. The script can be help to clear storage space on Nexus repository by analyzing the stats generated by the script. The script feature prompt-based user input, Search/Filter the results, Generates CSV output file and Print the output on console in a tabular format.
Nexus Space Utilization - GitHub
You may also refer below post on the same.
Nexus Space Utilization - Post

Deleting artifacts in artifactory

I want to delete artifacts in artifactory.I googled and found this link
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API
Here the Delete build,using REST API,is what we are going for at the moment.Can any one give me a general idea how the command should look using curl command.Also in buildname what do i need to specify?
For deleting a single artifact or folder you should use the Delete Item API, for example
curl -uadmin:password -XDELETE http://localhost:8080/artifactory/libs-release-local/ch/qos/logback/logback-classic/0.9.9
Notice that you will need a user with delete permissions.
If all goes well you should expect a response with a 204 status and no content.
The delete API is intended for deleting build information and is relevant if you are using the Artifactory build integration.
Nowadays there's a tool that can be used for it (note that I am a contributor to that tool):
https://github.com/devopshq/artifactory-cleanup
Assume i have 10 repositories and i want to keep only last 20 artifacts in 5 repositories and unlimited in other 5 repositories
The rule for 10 repositories would look like:
# artifactory-cleanup.yaml
artifactory-cleanup:
server: https://repo.example.com/artifactory
# $VAR is auto populated from environment variables
user: $ARTIFACTORY_USERNAME
password: $ARTIFACTORY_PASSWORD
policies:
- name: reponame
rules:
- rule: Repo
name: "reponame"
- rule: KeepLatestNFiles
count: 20

Resources