1

I built below using different portals. I have confusion in below lines of code.

  1. Can i use just docker push instead of ./jfrog rt dp. Does it make any difference if i use either of them.
  2. What's use of below lines of code. Is it required? Adding it makes any use. I see that i can see build info in JFROG. But i am already pushing my build to artifactory.
  • ./jfrog rt bce gitlabci-docker-artifactory $CI_JOB_ID
  • ./jfrog rt bp gitlabci-docker-artifactory $CI_JOB_ID
image: arielkv/dind-glibc:latest

services:
  - docker:dind
     stages:
    - Install
    - build

before_script:
  - apk update
  - apk add go curl
  - curl -fL https://getcli.jfrog.io | sh
  - ./jfrog rt config MyArtifactory --url $ARTIFACTORY_URL --user $ARTIFACTORY_USER --apikey $ARTIFACTORY_PASS
  - docker login -u $ARTIFACTORY_USER -p $ARTIFACTORY_PASS $ARTIFACTORY_DOCKER_REPOSITORY


Build:
    stage: build
    script:
    - docker build --rm=false --build-arg NODE_ENV=prod -t $ARTIFACTORY_DOCKER_REPOSITORY/artifactory-alpine:$CI_JOB_ID .
    - docker run -d -p 8081:8081 $ARTIFACTORY_DOCKER_REPOSITORY/artifactory-alpine:$CI_JOB_ID; sleep 10
    #- docker push $ARTIFACTORY_DOCKER_REPOSITORY/artifactory-alpine:$CI_JOB_ID
    - ./jfrog rt dp $ARTIFACTORY_DOCKER_REPOSITORY/artifactory-alpine:$CI_JOB_ID $DOCKER_REPOSITORY_KEY --build-name=gitlabci-docker-artifactory
--build-number=$CI_JOB_ID
    - ./jfrog rt bce gitlabci-docker-artifactory $CI_JOB_ID
    - ./jfrog rt bp gitlabci-docker-artifactory $CI_JOB_ID
    only:
    - master

1 Answer 1

0

1) You can certainly use docker push instead of using the JFrog CLI. To do that you'll need to execute three commands:

docker login myserver:8081
docker tag retgits/distroless-go:latest myserver:8081/docker/distroless-go:1
docker push myserver:8081/docker/distroless-go:1

In the commands

  • myserver:8081 is the name of the Artifactory server
  • docker is the name of the virtual repository
  • distroless-go:1 are the name and tag of the container

2a) The command ./jfrog rt bce gitlabci-docker-artifactory $CI_JOB_ID collects the environment variables of the current container or machine where the command is executed. Environment variables can be excluded using the build-publish command. In this specific command gitlabci-docker-artifactory is the build name that shows up in JFrog Artifactory and $CI_JOB_ID will be the build number.

2b) The command ./jfrog rt bp gitlabci-docker-artifactory $CI_JOB_ID will publish the collected build information (the environment variables and a few other bits of meta data) to JFrog Artifactory. In this specific command gitlabci-docker-artifactory is the build name that shows up in JFrog Artifactory and $CI_JOB_ID will be the build number

Edit after comment from OP:

The command docker push will get the docker image into JFrog Artifactory, but it will not capture the environment variables and some additional meta data generated during the build. If that is important, you'll want to run the two other commands too. If you only want to store the docker image, you don't have to use those commands (to be fair, most people I talk to and myself included, do upload those details to Artifactory to keep track of what went on during the build).

2
  • Are step 2a and 2b helpful? or just docker push will do.
    – Hacker
    Commented Apr 12, 2019 at 17:52
  • Good question! I've updated my answer to reflect that too, essentially only docker push is required but the other two commands might be helpful if you want to use the additional metadata (including env variables) later on.
    – retgits
    Commented Apr 12, 2019 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.