How do I use JFrog CLI with CircleCI 2.0?

docker

#1

I’m trying to use JFrog CLI with CircleCI 2.0 to publish my docker image into my JFrog artifactory, after some research I’ve found this tutorial: https://circleci.com/docs/1.0/Artifactory/ but it’s based on CircleCI 1.0 specification.

my config.yml file currently is:

version: 2
jobs:
  build:
    docker:
      - image: docker:17.05.0-ce-git
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Install dependencies
          command: |
            apk add --no-cache \
              py-pip=9.0.0-r1
            pip install \
              docker-compose==1.12.0 \
              awscli==1.11.76
      - run:
          name: Setup JFrog
          command: |
            wget http://dl.bintray.com/jfrog/jfrog-cli-go/1.7.1/jfrog-cli-linux-amd64/jfrog
            chmod +x jfrog
            ./jfrog rt config --url $ARTIFACTORY_URL --user $ARTIFACTORY_USER --apikey $ARTIFACTORY_PASSWORD
            docker login -e $ARTIFACTORY_EMAIL -u $ARTIFACTORY_USER -p $ARTIFACTORY_PASSWORD $ARTIFACTORY_DOCKER_REPOSITORY

But I’m getting the following error:

#!/bin/sh -eo pipefail
wget http://dl.bintray.com/jfrog/jfrog-cli-go/1.7.1/jfrog-cli-linux-amd64/jfrog
chmod +x jfrog
./jfrog rt config --url $ARTIFACTORY_URL --user $ARTIFACTORY_USER --apikey $ARTIFACTORY_PASSWORD
docker login -e $ARTIFACTORY_EMAIL -u $ARTIFACTORY_USER -p $ARTIFACTORY_PASSWORD $ARTIFACTORY_DOCKER_REPOSITORY
Connecting to dl.bintray.com (35.162.24.14:80)
Connecting to akamai.bintray.com (23.46.57.209:80)

jfrog                100% |*******************************|  9543k  0:00:00 ETA
/bin/sh: ./jfrog: not found
Exited with code 127

Does anyone know what is the correct way to use JFrog CLI with CircleCI 2.0?


#2

Hmm, odd. Can you add a temporary ls -l in there to see if jfrog is in there?

(Aside: I don’t know Bintray. Do they offer an https protocol link? It’s good practice to use that, or to check the hashes of the binary, before you use it).


#3

Hi @halfer, thanks for replying

Yes, they offer an https protocol, but when I try to use it, I’m getting this error:

Connecting to dl.bintray.com (108.168.243.150:443)
wget: can't execute 'ssl_helper': No such file or directory
wget: error getting response: Connection reset by peer
Exited with code 1 

So, I’ve decided to go forward and deal with https later.

About the jfrog cli binary, it’s is in the current folder as expected:

#!/bin/sh -eo pipefail
wget http://dl.bintray.com/jfrog/jfrog-cli-go/1.7.1/jfrog-cli-linux-amd64/jfrog
chmod +x jfrog
ls -l
./jfrog rt config --url $ARTIFACTORY_URL --user $ARTIFACTORY_USER --apikey $ARTIFACTORY_PASSWORD
docker login -e $ARTIFACTORY_EMAIL -u $ARTIFACTORY_USER -p $ARTIFACTORY_PASSWORD $ARTIFACTORY_DOCKER_REPOSITORY
Connecting to dl.bintray.com (108.168.243.150:80)
Connecting to akamai.bintray.com (23.46.57.209:80)

jfrog                100% |*******************************|  9543k  0:00:00 ETA
total 9568
-rw-r--r--    1 root     root           197 May 11 16:01 Dockerfile
-rw-r--r--    1 root     root           461 May 11 16:01 Makefile
-rw-r--r--    1 root     root           181 May 11 16:01 README.md
drwxr-xr-x    4 root     root          4096 May 11 16:01 bootstrap
-rw-r--r--    1 root     root           528 May 11 16:01 docker-compose.yml
drwxr-xr-x    2 root     root          4096 May 11 16:01 environment
-rwxr-xr-x    1 root     root       9772523 May 11 16:01 jfrog
/bin/sh: ./jfrog: not found
Exited with code 127

#4

That’s because you need to install openssl to use HTTPS connections :smile:


#5

The execution issue is very odd. Maybe try mv jfrog /bin/jfrog? You can then do jfrog on its own, without the dot-slash prefix.

The only other thing I can think of is that you’ve downloaded one for the wrong arch, and so it is found, but the error is misleading.


#6

Great, now I can download JFrog CLI through https thanks.

Moving the binary to /bin folder didn’t work as well

#!/bin/sh -eo pipefail
wget https://dl.bintray.com/jfrog/jfrog-cli-go/1.7.1/jfrog-cli-linux-amd64/jfrog -P /bin/
chmod +x /bin/jfrog
ls -l /bin
jfrog rt config --url $ARTIFACTORY_URL --user $ARTIFACTORY_USER --apikey $ARTIFACTORY_PASSWORD
docker login -e $ARTIFACTORY_EMAIL -u $ARTIFACTORY_USER -p $ARTIFACTORY_PASSWORD $ARTIFACTORY_DOCKER_REPOSITORY
Connecting to dl.bintray.com (52.27.110.215:443)
Connecting to akamai.bintray.com (23.46.62.15:443)
jfrog                100% |*******************************|  9543k  0:00:00 ETA
total 70068
...
-rwxr-xr-x    1 root     root       9772523 May 11 16:14 jfrog
...
/bin/sh: jfrog: not found
Exited with code 127

Still looking for a solution :persevere:


#7

I guess the binary is not wrong, because I got it from an oficial jfrog post https://jfrog.com/blog/fully-reproducible-builds-with-circleci-and-artifactory/


#8

Is this binary available through a package manager, say NPM?


#9

Just found it here https://www.npmjs.com/package/jfrog-cli-go but I’m not sure how to install it in circleci


#10

I’d try something like apk add npm && npm install jfrog-cli-go. You could get an SSH session from your existing build (even if it fails) and then play around in the console, to trial-and-error a load of commands.


#11

Does the ssh work for free accounts?

I’ve tried to “Rebuild with SSH” but got time out error
ssh: connect to host 34.207.213.43 port 64546: Connection timed out


#12

Yep, completely. Check your dev machine or premises outbound firewall.

Remember to cancel it in the UI after you have finished with it, it tends to eat build minutes!


#13

hey @halfer,

Now it works, thank you a lot I really appreciated your help!

Here is how my config.yml file is looking like now:

version: 2
jobs:
  build:
    docker:
      - image: docker:17.05.0-ce-git
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Install dependencies
          command: |
            apk add --no-cache \
              py-pip=9.0.0-r1 \
              openssl \
              nodejs
            pip install \
              docker-compose==1.12.0 \
              awscli==1.11.76
      - run:
          name: Setup JFrog
          command: |
            npm install -g jfrog-cli-go
            jfrog rt config --url $ARTIFACTORY_URL --user $ARTIFACTORY_USER --apikey $ARTIFACTORY_PASSWORD
            docker login -u $ARTIFACTORY_USER -p $ARTIFACTORY_PASSWORD $ARTIFACTORY_DOCKER_REPOSITORY

#14

No worries, well done for persisting on it! :nerd_face:


#15