Jenkins build Docker raise error Unrecognized field "ExecDriver" - jenkins

I'm integrating Docker with Jenkins, but the build is showing the following error
VERSIONS
- Jenkins version 1.555
- Docker version 0.9.0
Jenkins Plugins
- Mercurial (to pull code from bitbucket)
- Docker (docker-plugin)
- docker-build-step
[Docker] INFO: created container id e463f956d2d4.... (from image my-base)
FATAL: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "ExecDriver"
docker-build-step

I assume that the Docker plugin for Jenkins is very strict about what it expects, and when Docker 0.9 returns an ExecDriver value (for instance, in docker inspect) it gets confused.
The easiest fix is, as you did, roll back to 0.8; but it would be better to fix the Jenkins module; either by using semver (Docker API is versioned) or by making the code accept the ExecDriver attribute optionally.

Related

Using latest Docker image in BitBucket pipe command

I have a Bitbucket pipeline that runs a pipe using a version number tag as follows:
script:
- mkdir meta
- pipe: myteam/bladepackager-pipeline:1.0.8
variables: ...
I would prefer to have it automatically resolve the latest tagged version of the Docker image, so I tried:
script:
- mkdir meta
- pipe: myteam/bladepackager-pipeline:latest
variables: ...
But I get an error message from my BitBucket pipeline run that says
Your pipe name is in an invalid format. Check the name of the pipe and try again.
Is there a way to specify latest rather than a specific tag?
The tag latest, itself is a tag, it does not mean the latest tag. so if you want to use images with this tag, you have to make docker with that tag.
The
- pipe: aaa/bbbb:1.2.3
syntax refers to a git repository hosted in the bitbucket, e.g. bitbucket.org/aaa/bbbb, whereas the
- pipe: docker://registry.example.com/aaa/bbbb:tag
refers to a docker image in any registry.
The :latest tag can only be used with the docker syntax. For the bare pipe syntax I guess you can only try git refs? Maybe :main or :master would be valid? Never managed it to work, please reach back if you succeed.

DockerPush Fails from Jenkins to Jfrog Docker Registry

We have a docker image say xyz:latest which needs to be pushed to my docker registry xxx.com at repo "docker-local" via Jenkins Pipeline
Things were working fine earlier but after updating the artifactory plugins over Jenkins, we are facing the issue with
"INFO: The search failed with "Failed to retrieve repository configuration 'docker-local': HTTP/1.1 400 Bad Request"."
With reference to the code given at (https://www.jfrog.com/confluence/display/JFROG/Setting+Up+Docker+Build-info), more particularly the step 3 part of it, can someone please explain out what does it exactly mean??
// Step 3: Push the image to Artifactory.
// Make sure that <artifactoryDockerRegistry> is configured to reference <targetRepo> Artifactory repository. In cas
def buildInfo = rtDocker.push '<artifactoryDockerRegistry>/hello-world:latest', '<targetRepo>'.
What my values currently for them are:
artifactoryDockerRegistry: "xxx.com/docker-local/xyz:latest"
targetRepo: "docker-local"
Somehow I land-up with the error as mentioned in the comments section of Step3 above.
Can someone please help me with a generic example as to what should the values be??

Invalid agent type "call" specified. Must be one of [any, docker, dockerfile, kubernetes, label, none]

We are using the code below to spin up a kubernetes cloud docker agent in Jenkins:
agent {
docker { image 'golang:1.14' }
}
We get the error below:
14:55
I get;
WorkflowScript: 158: Invalid agent type "call" specified. Must be one of [any, docker, dockerfile, kubernetes, label, none] # line 158, column 17.
docker { image 'golang:1.14' }
^
Any ideas how to fix this, please?
We have a jenkins.gdsl file which could be in the mix. Any ideas whether this is the right direction to follow? (We are not even sure what a gdsl file is!)
Probably you have to install both plugins:
Docker Pipeline
Docker plugin + deps(Auto)
Not very well explained on the doc and it seems the main plugin Docker plugin does not install Docker Pipeline by default.
See here Using Docker with Pipeline
You should install docker plugins to be able to use Docker in Jenkins.
Go to manage Jenkins.
Manage Plugins.
Install:
Docker pipeline
Docker
You should see the following plugins installed:
Optionally restart Jenkins.

Jenkins user not in passwd on dynamic jnlp slave in kubernetes

I am building a system to do c++ cmake builds primarily. I have Jenkins firing the dynamic pods, firing off shell scripts, etc. But, I can't get it to checkout the code. Now, my Jenkinsfile launches a container that the actual compile is supposed to be run in. That "sub" container is tuned to compile C++ code. Now, I have jenkins running scripts and such in that pod, but, when i try
checkout scm
im getting errors saying
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --force --progress git#gitlab.com:mystuff/hello-world-cmake.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: No user exists for uid 1000080000
fatal: Could not read from remote repository.
my home folder is the standard /home/jenkins and the workspace folder is there, etc, etc. But, when I dump the /etc/passwd file, the jenkins user isn't listed in it.
Whats the appropriate way to add the jenkins user to that file?
What image are you using for Jenkins slave? Does it have user jenkins? If it has you need to specify this in your spec for Jenkins slave:
spec:
securityContext:
runAsUser: 1000
UPDATE:
You cannot run default Jenkins image in Openshift, because Openshift runs containers as random user. You should run Jenkins from builtin Jenkins template "Jenkins Persistent". If you don't have this template and don't have Jenkins image stream - you can try to use image openshift/jenkins-2-centos7. See details at:
https://github.com/openshift/jenkins/issues/168
https://github.com/openshift/jenkins

Can not push Docker Image to Artifactory in Jenkins pipeline using Artifactory plugin

I'm using a Docker Registry on Artifactory. I'm able to pull/push images using docker commands. Now I try to push an image using a Jenkins pipline.
The image is called registry-url/docker/image:latest.
I have a docker repository on Artifactory which is called docker. (I'm able to pull and push to this repo using docker commands).
This stage describes my Artifactory configuration:
...
stage('Deploy Docker image'){
steps {
script {
def server = Artifactory.server 'xxx'
def rtDocker = Artifactory.docker server: server
def buildInfo = rtDocker.push('registry-url/image:latest', 'docker')
//also tried:
//def buildInfo = rtDocker.push('registry-url/docker/image:latest', 'docker')
//the above results in registry/docker/docker/image..
server.publishBuildInfo buildInfo
}
}
}
...
When I use different paths I face the manifest.json error which is probably normal.
I'm able to download the manifest.json manually on: https://registry-url/artifactory/docker/image/latest/manifest.json.
I'm using a pretty new version of Docker on Jenkins:
Docker version 18.01.0-ce, build 03596f51b1
So far so good. But When I run the pipeline I receive the following error in Jenkins (it takes 50 seconds):
Pushing image: registry-url/image:latest
...
com.github.dockerjava.api.exception.DockerClientException: Could not push image: unknown: Not Found
at com.github.dockerjava.core.command.PushImageResultCallback.awaitSuccess(PushImageResultCallback.java:49)
at org.jfrog.hudson.pipeline.docker.utils.DockerUtils.pushImage(DockerUtils.java:60)
at org.jfrog.hudson.pipeline.docker.utils.DockerAgentUtils$3.call(DockerAgentUtils.java:213)
at org.jfrog.hudson.pipeline.docker.utils.DockerAgentUtils$3.call(DockerAgentUtils.java:205)
at hudson.remoting.UserRequest.perform(UserRequest.java:153)
at hudson.remoting.UserRequest.perform(UserRequest.java:50)
...
In Artifactory logs I see:
2018-04-25 14:24:26,663 [http-nio-8081-exec-xx] [ERROR] (o.a.a.d.r.DockerResource:153) - Unsupported docker v2 repository request for 'image'
2018-04-25 14:24:46,684 [http-nio-8081-exec-xx] [ERROR] (o.a.a.d.r.DockerResource:153) - Unsupported docker v2 repository request for 'image'
2018-04-25 14:24:46,689 [http-nio-8081-exec-xx] [ERROR] (o.a.a.d.r.DockerResource:153) - Unsupported docker v2 repository request for 'image'
2018-04-25 14:24:46,702 [http-nio-8081-exec-xx] [ERROR] (o.a.a.d.r.DockerResource:153) - Unsupported docker v2 repository request for 'image'
What am I missing or doing wrong?
EDIT:
Based on this issue I went back to my initial idea:
def buildInfo = rtDocker.push('registry-url/docker/image:latest', 'docker')
I tried the build again. Error:
Could not find manifest.json in Artifactory in the following path: https://registry-url/artifactory/docker/docker/image/latest/manifest.json
Two times 'docker' in the path and it seems not to work. BUT when I check in Artifactory the image is there... I can also pull the image. It seems to be fine but still the jenkins build is failing.
Artifactory Plugin: 2.15.1
Artifactory Version: 5.10.3
Is this really a bug which will be fixed soon?
Artifcatory can be configured as a docker registry either with or without a reverse proxy.
It looks like your Artifactory is not configured using a reverse-proxy (proxy-less configuration). You can read more about the configuration options here.
Version 2.16.1 of the Jenkins Artifactory Plugin added support for proxy-less configuration. Upgrading your Artifactory Plugin should resolve your issue.
Try following this example. Here we have Jenkins pipeline to pull/push docker image to/from Artifactory: https://github.com/jfrogtraining/kubernetes_example/blob/master/docker-app/Jenkinsfile#L43

Resources