How can I automatically accept Artifactory EULA? - artifactory

I have been using Artifactory OSS and set it up with a deploy script. The deploy script also uploads some images with curl to a generic repo immediately after setup. Now I need to upload docker images as well so I made the switch to Artifactory JCR. JCR won't accept my curl push until I have accepted the EULA. Is it possible to accept it automatically? I have been looking for a EULA flag in files and the database but without success.
My environment is a docker container with artifactory-jcr:6.17.0 in Kubernetes.

One more option is to use this curl in the script, after JFrog Container Registry is installed:
curl -XPOST -vu username:password http://${ArtifactoryURL}/artifactory/ui/jcr/eula/accept

For deployments using a scripts, you can sign the JCR EULA in a YAML configuration file you have prepared ahead. As JCR is based on Artifactory, the configuration files are usually similar.
Create a YAML file at $JCR_HOME/etc/artifactory.config.import.yml
Add the below
GeneralConfiguration:
eula:
accepted: true
OnboardingConfiguration:
repoTypes:
- docker
- helm
Make sure to format it as YAML before writing to the file

Related

Artifactory: Converting remote repo to local repo

My employer has been misusing Bintray as our binary repository for some time. We are finally moving to Artifactory instead and closing down Bintray. But this seems to be an almost impossible task. There is no way of exporting Bintray repos to a zip. Downloading the repos means manually downloading each file from the UI or through their API. I have tried two approaches for automation:
1) wget for crawling our bintray like this:
wget -e robots=off -o ~/wget.log -w 1 -m -np --user --password "https://.bintray.com"
which yielded all of the files in the repos. But this only solves half the problem. I couldn't find out how to import the files to a repository in artifactory (all the repos are over 100mbs each and therefore can't be uploaded, for some reason).
2) I set the Bintray repos up as remote repositories and enabled Active Replication. That seems to have worked for now. But I don't know if they will be removed when the Bintray account is moved or even if they are stored in Artifactory. Therefore I would like to convert the remote repo to a local repo, to make sure that it is permanently stored in artifactory is there a way of doing this? If so, how?
I'll try to address both of your questions below.
What do you mean you can't upload more than 100mb? Which version of Artifactory are you using? On-prem or SaaS-based installation? How are you trying to upload your files to Artifactory? Have you tried to import the content by using the import feature of Artifactory? (Admin --> Import&Export --> repository Import)
It sounds like you are using the UI for the upload, and if so you can configure the max upload size in Admin --> General Configuration page.
If you mean that you have all of the content from Bintray cached in your remote repository cache in Artifactory just use the "Copy" or "Move" option and move the content to a local repository. This will ensure that all of the content is stored locally.

jfrog rest api: Deploying jars with group id and Artifact id

I have been trying to upload my application specific JARs to the JFrog Artifactory using the rest API but couldn't find any methods to include the group id and the artifact id like maven does.
This command does deploy the jar to repository but without the groupId and artifactId;
curl -u username:password -X PUT "http://xx.xx.xxx.xx:8081/artifactory/libs-release-local/mail-1.4.3.jar" -T mail-1.4.3.jar
Are there any way that I could mention the Group id and Artifact Id while uploading the JARS to artifactory using Jfrog Rest API ?
There is nothing that will do it automatically for you, but you can definitely specify a full path that includes the groupId, artifactId and version of your artifact exactly like Maven would, i.e:
curl -u username:password -T mail-1.4.3.jar "http://xx.xx.xxx.xx:8081/artifactory/libs-release-local/org/someOrg/mail/1.4.3/mail-1.4.3.jar"
(p.s - you don't need to specify -XPUT if you specify -T)
BTW - unlike the REST API, the Artifactory UI does actually have the ability to fill in the full maven coordinates for you during upload. Have a look here:
https://www.jfrog.com/confluence/display/RTF/Deploying+Artifacts#DeployingArtifacts-DeployingMavenArtifacts

push package builded in Gitlab CI.Runner to Nexus repository

In Gitlab issue #19095 it's decided to leverage GL as package repository, but what should i do just now, until it's not done, for task: "try that Gitlab instead Jenkins+Nexus". From which place can I push package to Nexus?
from gitlab-ci.yml
using uploaded package from Runner using artifacts parameter gitlab-ci.yml https://about.gitlab.com/2015/11/22/gitlab-8-2-released/
from Docker image using Maven may be
via webhook
using release tag?
The best answer I think you're going to find is that you need to write it into your gitlab yml script
NEXUS_USERNAME=admin
NEXUS_PASSWORD=admin123
NEXUS_SERVER=server.com/yourserver
NEXUS_REPOSITORY=raw
echo "Sending backup to server"
curl -v -u ${NEXUS_USERNAME}:${NEXUS_PASSWORD} --upload-file ${UPLOAD_FILE} http://${NEXUS_SERVER}/repository/${NEXUS_REPOSITORY}/${UPLOAD_FILE}

Docker: how to manage development and production settings?

I'm just getting started with Docker. With the official NGINX image on my OSX development machine (with Docker Machine as the Docker host) I ran up against the bug with sendfile and VirtualBox which means the server fails to show changes I make to files.
The workaround for this is to use a modified nginx.conf file that turns off sendfile. This guy's solution has an instruction in the Dockerfile to copy a customised conf file into the container. Alternatively, this guy maps the NGINX configuration to a new folder with modified conf file.
This kind of thing works OK locally. But what if I don't need this modification on my cloud host? How should I handle this and other differences when it comes to deployment?
You could mount your custom nginx.conf into the container in development via e.g. --volume ./nginx/nginx.conf:/etc/nginx/nginx.conf and simply omit this parameter to docker run in production.
If using docker-compose, the two options I would recommend are:
Employ the limited support for environment variable interpolation and add something like the following under volumes in your container definition: ./nginx/nginx.${APP_ENV}.conf:/etc/nginx/nginx.conf
Use a separate YAML file for production overrides.

Is there a URL for the latest snapshot for an artifact in Artifactory?

I would like to make a permalink to the latest snapshot version of an artifact in Artifactory. If we are on 1.0-SNAPSHOT, I would like a URL that downloads the latest 1.0-SNAPSHOT JAR. I can find the latest artifact by locating the artifact on our server at http://hostname/artifactory/libs-snapshot/groupId/artifactId/1.0-SNAPSHOT/. Other than checking the timestamps, I can figure out which one if the latest by opening maven-metadata.xml and matching metadata/versioning/snapshot timestamp and buildNumber with a JAR in the same directory. This could be scripted, but ideally Artifactory already has a way to construct a permalink in this manner. Does Artifactory provide such a URL?
Doing the normal query for the entry with artifactId-1.0-SNAPSHOT.jar in the URL name should return automatically the latest snapshot.
See the doc here
One thing: This is base either on the latest creation date if no pom present, or latest creation of the pom if there are some. Mixing pom and non-pom deployment may results in strange results!
I tried using shell script and it worked for me.
Step1: Get an encrypted password for your user account by clicking on user name or create a common user. Go to using your secure password section in the following link
http://www.jfrog.com/confluence/display/RTF/Centrally+Secure+Passwords
Step 2: In your local machine create a temp folder and type this curl(may be wget for windows) command:
curl -o tmp/foo.jar --user <username>:<encrypted_password> <artifactory_url>/list/libs-snapshot-local/com/search/foo/1.0/foo-1.0-SNAPSHOT.JAR
Your foo.jar in tmp folder is latest version. If we dont give timestamp as like above, it will download latest artifact in that version. Hope this helps!
This might be helpful:
How to download the latest artifact from Artifactory repository?
Although there is no permalink ability in the free version of Artifactory, it can be scripted easily as you suggest. I have provided a quick script to do that in the referenced question.
Hope it helps.
Another portable option is to use the maven command line:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DartifactId=[artifactId] -DgroupId=[groupId] -Dversion=[version] -Ddest=[dest file]
This works for me (no search API, just direct artifact URL):
curl -O -J --user <username>:<encrypted_password> http://hostname/artifactory/libs-snapshot/groupId/artifactId/1.0-SNAPSHOT/artifactId-1.0-SNAPSHOT.jar
Basically using 1.0-SNAPSHOT in the artifact name downloads the latest version of 1.0-SNAPSHOT snapshot.

Resources