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:
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?
Found the solution:
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'
)
}
}