3
votes

I'm trying to configure new pipeline in Jenkins. I have purchased and installed jFrog artifactory pro on Windows Server and it's up and running at: https://artifactory.mycompany.com

I found this sample here: https://github.com/jfrog/project-examples/blob/master/jenkins-examples/pipeline-examples/declarative-examples/docker-push-example/Jenkinsfile

More specifically this section:

stage ('Push image to Artifactory') {
        steps {
            rtDockerPush(
                serverId: "ARTIFACTORY_SERVER",
                image: ARTIFACTORY_DOCKER_REGISTRY + '/hello-world:latest',
                // Host:
                // On OSX: "tcp://127.0.0.1:1234"
                // On Linux can be omitted or null
                host: HOST_NAME,
                targetRepo: 'docker-local',
                // Attach custom properties to the published artifacts:
                properties: 'project-name=docker1;status=stable'
            )
        }
    }

It's building and creating docker image but when it gets to push image it fails to push the image and errors out. Not sure what should go in the following:

  • ARTIFACTORY_DOCKER_REGISTRY
  • host: HOST_NAME

I've created a new local repo in artifactory "docker-local". Tried omitting host and getting

"Unsupported OS".

Putting host back in with "host: 'tcp://IP ADDRESSS" or "artifactory.mycompany.com:80/artifactory" generates

"Unsupported protocol scheme"

How would one configure jenkins pipeline to work with jFrog artifactory?

1
What error is being returned?Matt Schuchard
@MattSchuchard i've listed those above. Not sure what value to use in "Host" and "ARTIFACTORY_DOCKER_REGISTRY". is "ARTIFACTORY_DOCKER_REGISTRY" expected name of Local-docker registry?ShaneKm
So that code appears to use more recent global var methods. The older class methods always worked consistently for me. You may have run into a bug since this is supported under a new major release.Matt Schuchard
@MattSchuchard can you please let me know what values should be populated for those variables? What should go in HOST_NAME & ARTIFACTORY_DOCKER_REGISTRY?ShaneKm

1 Answers

2
votes

Found the solution:

  • ARTIFACTORY_DOCKER_REGISTRY should be IP/Artifactory-Repo-Key/Image:Tag
  • HOST should be docker daemon (Docker for windows is localhost:2375)

        stage('Build image') { // build and tag docker image
            steps {
                echo 'Starting to build docker image'
    
                script {
                    def dockerfile = 'Dockerfile'
                    def customImage = docker.build('10.20.111.23:8081/docker-virtual/hello-world:latest', "-f ${dockerfile} .")
    
                }
            }
        }
    
        stage ('Push image to Artifactory') { // take that image and push to artifactory
            steps {
                rtDockerPush(
                    serverId: "jFrog-ar1",
                    image: "10.20.111.23:8081/docker-virtual/hello-world:latest",
                    host: 'tcp://localhost:2375',
                    targetRepo: 'local-repo', // where to copy to (from docker-virtual)
                    // Attach custom properties to the published artifacts:
                    properties: 'project-name=docker1;status=stable'
                )
            }
        }