Jenkins fails to build with docker - docker

I'm trying to build my Maven project with Jenkins and Docker.
I prepared following Jenkinsfile inside my repository.
pipeline {
agent none
stages {
stage('3-jdk-8') {
agent {
docker {
registryUrl 'https://registry.hub.docker.com'
registryCredentialsId 'docker-hub'
image 'maven:3-jdk-8'
args '-v $HOME/.m2:/root/.m2'
reuseNode true
}
}
steps {
sh 'mvnw -B clean build'
}
}
stage('3-jdk-11') {
agent {
docker {
registryUrl 'https://registry.hub.docker.com'
registryCredentialsId 'docker-hub'
image 'maven:3-jdk-11'
args '-v $HOME/.m2:/root/.m2'
reuseNode true
}
}
steps {
sh 'mvnw -B clean build'
}
}
}
}
When I trigger the item, I got this.
Started by user Jin Kwon
Checking out git https://....git into /var/lib/jenkins/workspace/...#script to read Jenkinsfile
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
using credential ...
> git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/...#script/.git # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://....git # timeout=10
Fetching upstream changes from https://....git
> git --version # timeout=10
> git --version # 'git version 2.25.1'
using GIT_ASKPASS to set credentials
> git fetch --tags --force --progress -- https://....git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse origin/develop^{commit} # timeout=10
Checking out Revision c9627132515a20c209a6e0d5f14c3779fa1eb933 (origin/develop)
> git config core.sparsecheckout # timeout=10
> git checkout -f c9627132515a20c209a6e0d5f14c3779fa1eb933 # timeout=10
Commit message: "Configure docker.registry(Url|registryCredentialId)"
> git rev-list --no-walk c9627132515a20c209a6e0d5f14c3779fa1eb933 # timeout=10
[Pipeline] Start of Pipeline
[Pipeline] stage
[Pipeline] { (3-jdk-8)
[Pipeline] getContext
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/...
[Pipeline] {
[Pipeline] checkout
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
using credential ...
> git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/.../.git # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://....git # timeout=10
Fetching upstream changes from https://....git
> git --version # timeout=10
> git --version # 'git version 2.25.1'
using GIT_ASKPASS to set credentials
> git fetch --tags --force --progress -- https://....git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse origin/develop^{commit} # timeout=10
Checking out Revision c9627132515a20c209a6e0d5f14c3779fa1eb933 (origin/develop)
> git config core.sparsecheckout # timeout=10
> git checkout -f c9627132515a20c209a6e0d5f14c3779fa1eb933 # timeout=10
Commit message: "Configure docker.registry(Url|registryCredentialId)"
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withDockerRegistry
Using the existing docker config file.Removing blacklisted property: auths$ docker login -u onacit -p ******** https://registry.hub.docker.com
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /var/lib/jenkins/workspace/...#tmp/950e743c-139b-4e14-93c3-b9fda206b1f4/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . maven:3-jdk-8
Error: No such object: maven:3-jdk-8
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . registry.hub.docker.com/maven:3-jdk-8
Error: No such object: registry.hub.docker.com/maven:3-jdk-8
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker pull registry.hub.docker.com/maven:3-jdk-8
Error response from daemon: unauthorized: authentication required
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withDockerRegistry
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (3-jdk-11)
Stage "3-jdk-11" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

Jenkins (Docker Daemon) cannot find the image. Or in other words cannot find the registry.
+ docker pull registry.hub.docker.com/maven:3-jdk-8
Error response from daemon: unauthorized: authentication required
You just need to modify the registry URL in the config with docker.io like this.
stage('3-jdk-8') {
agent {
docker {
registryUrl 'https://docker.io'
registryCredentialsId 'docker-hub'
image 'maven:3-jdk-8'
args '-v $HOME/.m2:/root/.m2'
reuseNode true
}
}
Or you can omit the registryUrl and registryCredentialsId since the maven image is in the public registry (Docker Hub). And Jenkins will try to pull it from there by default.
stage('3-jdk-8') {
agent {
docker {
image 'maven:3-jdk-8'
args '-v $HOME/.m2:/root/.m2'
reuseNode true
}
}

Related

Jenkins pipeline can't pull docker image

I am currently facing a situation whereby I can't pull a docker image during my Jenkins pipeline. Jenkins is running in a container as advised in the Jenkins Documentation
Whenever I run my pipeline, I come across the following error:
Started by user piii
Replayed #32
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/lms-portal
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
using credential 9d587d39-cf26-4eba-b08e-d9732a70a5b9
> git rev-parse --resolve-git-dir /var/jenkins_home/workspace/lms-portal/.git # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/Piii-thagorus/lms_portal.git # timeout=10
Fetching upstream changes from https://github.com/Piii-thagorus/lms_portal.git
> git --version # timeout=10
> git --version # 'git version 2.30.2'
using GIT_SSH to set credentials jenksins_ssh
[INFO] SELinux is present on the host and we could not confirm that it does not apply actively: will try to relabel temporary files now; this may complain if context labeling not applicable after all
> /usr/bin/chcon --type=ssh_home_t /var/jenkins_home/workspace/lms-portal#tmp/jenkins-gitclient-ssh9208860798294607535.key
Verifying host key using known hosts file
You're using 'Known hosts file' strategy to verify ssh host keys, but your known_hosts file does not exist, please go to 'Manage Jenkins' -> 'Configure Global Security' -> 'Git Host Key Verification Configuration' and configure host key verification.
> git fetch --tags --force --progress -- https://github.com/Piii-thagorus/lms_portal.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/testing^{commit} # timeout=10
Checking out Revision 3e0e59d57c873b5869628455c28fc82d66f1570f (refs/remotes/origin/testing)
> git config core.sparsecheckout # timeout=10
> git checkout -f 3e0e59d57c873b5869628455c28fc82d66f1570f # timeout=10
Commit message: "Removed docker as agent"
> git rev-list --no-walk 3e0e59d57c873b5869628455c28fc82d66f1570f # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ docker inspect -f . node:latest
error during connect: Get "https://docker:2376/v1.24/containers/node:latest/json": dial tcp: lookup docker: no such host
[Pipeline] isUnix
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ docker pull node:latest
error during connect: Post "https://docker:2376/v1.24/images/create?fromImage=node&tag=latest": dial tcp: lookup docker: no such host
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
Below is my pipeline, There
pipeline {
agent {
docker { image 'node:latest' }
}
stages {
stage('Prepare'){
steps{
sh 'echo "starting"'
}
}
}
}
What can be the cause of this? Any solution is appreciated.
Thank you
From what I understood you are running Jenkins as a container, and you want to run a build in which you require to pull a docker container.
If I am correct, let me make it clear.
You are running Jenkins as a docker container which means you do not have a local installation of Jenkins where you are running docker. Nor does Jenkins container run docker so you are trying to pull a docker container from where you do not have docker.
There is a work around for the same. You can install docker plugin and configure it.
Find the plugin documentation here
Also, you can try doing this.
There is a section in second hyperlink which shows how to configure docker agent before you use it.
Hope this helps,
Have a great day.

Jenkins K8s plugin WebSocket Timeout in container step

I have created a K3d cluster. I've Deployed a jenkins 2.319.1 controller inside, along with kubernetes plugin 1.31.1 (and git, pipeline and the like)
The idea is to run both the controller and the agents in the same cluster. To do so I've configured a cloud like in this picture:
[Cloud Configuration ][1]
[1]: https://i.stack.imgur.com/u91Fr.png
(I've done several attempts with different combinations for the agents to connect to the controller. Finally I've stayed with JNLP - NO WEBSOCKET - although, anyway, the timeout I'm about to describe is common to both of them)
With the cloud configured and being able to spawn the agents, after many attempts I finally discovered that the job was hanging (and dying of timeout) in the execution inside a container step. Actions within the default "jnlp" container are ok but the moment you do something as trivial as: sh 'ls -l' inside another container the job dies after 30 seconds with the following log:
> .
.
.
.
readOnly: false
nodeSelector:
kubernetes.io/os: "linux"
restartPolicy: "Never"
volumes:
- emptyDir:
medium: ""
name: "workspace-volume"
Running on prueba-6-tj9w5-r0qt9-kcst4 in /home/jenkins/agent/workspace/Prueba
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Get a Maven project)
[Pipeline] sh
+ git config --global http.proxy http://10.11x.xx.xx:8080
[Pipeline] sh
+ git config --global https.proxy http://10.11x.xx.xx:8080
[Pipeline] git
The recommended git tool is: NONE
No credentials specified
Cloning the remote Git repository
Cloning repository https://github.com/jenkinsci/kubernetes-plugin.git
> git init /home/jenkins/agent/workspace/Prueba # timeout=10
Fetching upstream changes from https://github.com/jenkinsci/kubernetes-plugin.git
> git --version # timeout=10
> git --version # 'git version 2.30.2'
> git fetch --tags --force --progress -- https://github.com/jenkinsci/kubernetes-plugin.git +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
Checking out Revision a61114b275425489761f095e8a89b19cf2ab5c8e (refs/remotes/origin/master)
> git config remote.origin.url https://github.com/jenkinsci/kubernetes-plugin.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git config core.sparsecheckout # timeout=10
> git checkout -f a61114b275425489761f095e8a89b19cf2ab5c8e # timeout=10
> git branch -a -v --no-abbrev # timeout=10
> git checkout -b master a61114b275425489761f095e8a89b19cf2ab5c8e # timeout=10
Commit message: "[maven-release-plugin] prepare for next development iteration"
First time build. Skipping changelog.
[Pipeline] container
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build a Maven project)
[Pipeline] sh
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
java.io.IOException: Timed out waiting for websocket connection. You should increase the value of system property org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator.websocketConnectionTimeout currently set at 60 seconds
at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1.doLaunch(ContainerExecDecorator.java:457)
at org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator$1.launch(ContainerExecDecorator.java:344)
at hudson.Launcher$ProcStarter.start(Launcher.java:507)
.
.
.
I don't know the websocket message as in the cloud configuration this is clearly unchecked. As I mention if I check websocket (along with clearing tunnel) I get the same result.
I don't know if this has anything to do with jenkins running inside a dockerized cluster. I have installed the same cluster (k3d v4.4.7) both in wsl2 in windows and also in rhel 7.9.
Sample pipeline used (this last one borrowed from ):
> podTemplate(containers: [
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'golang', image: 'golang:1.8.0', ttyEnabled: true, command: 'cat')
]) {
node(POD_LABEL) {
env.http_proxy='http_proxy=http://10.11x.xx.xx:8080'
env.https_proxy='http_proxy=http://10.11x.xx.xx:8080'
stage('Get a Maven project') {
sh 'git config --global http.proxy http://10.11x.xx.xx:8080'
sh 'git config --global https.proxy http://10.11x.xx.xx:8080'
git 'https://github.com/jenkinsci/kubernetes-plugin.git'
container('maven') {
stage('Build a Maven project') {
sh 'mvn -B clean install'
}
}
}
stage('Get a Golang project') {
git url: 'https://github.com/hashicorp/terraform.git'
container('golang') {
stage('Build a Go project') {
sh """
mkdir -p /go/src/github.com/hashicorp
ln -s `pwd` /go/src/github.com/hashicorp/terraform
cd /go/src/github.com/hashicorp/terraform && make core-dev
"""
}
}
}
}
}
Regards
As mentioned in previous comment referring to post (Jenkins with Kubernetes Client Plugin - NoSuchMethodError) upgrading kubernetes plugin to v1.31.2 solved the problem. Already patched and tested.
KR

why the jenkins pipeline could not access some secret

I am define some secret credential in jenkins, and now I using it in jenkins pipeline like this:
pipeline {
agent {
node {
label 'jenkins-master'
}
}
environment {
GITHUB_USERNAME = credentials('github-username')
GITHUB_PASSWORD = credentials('github-password')
GITHUB_PASSWORD1 = credentials('github-password-1')
df = credentials('123')
}
stages {
stage('checkout-source') {
steps {
git credentialsId: 'gitlab-project-auth',
url: 'https://github.com/jiangxiaoqiang/jiangxiaoqiang.github.io.git'
}
}
stage('publish') {
steps{
sh "git config --global user.email \"jiangtingqiang#gmail.com\""
sh "git config --global user.name \"jiangxiaoqiang\""
sh "git add -A"
sh "git diff-index --quiet HEAD || git commit -m \"[docs] scheduled auto commit task\" || git push"
sh "echo ${GITHUB_USERNAME}"
sh "echo ${GITHUB_PASSWORD}"
sh "echo ${GITHUB_PASSWORD1}"
sh "echo ${df}"
sh "git push https://${GITHUB_USERNAME}:${GITHUB_PASSWORD}#github.com/jiangxiaoqiang/jiangxiaoqiang.github.io.git"
}
}
}
}
but it seems only the first works, this is the build log output:
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/****/xiaoqiang-blog-source.git # timeout=10
Fetching upstream changes from https://github.com/****/xiaoqiang-blog-source.git
> git --version # timeout=10
> git --version # 'git version 2.11.0'
> git fetch --tags --progress -- https://github.com/****/xiaoqiang-blog-source.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision d24abcbc136a3f050b9c1aa365bf30dcc6b77bb9 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f d24abcbc136a3f050b9c1aa365bf30dcc6b77bb9 # timeout=10
> git branch -a -v --no-abbrev # timeout=10
> git branch -D master # timeout=10
> git checkout -b master d24abcbc136a3f050b9c1aa365bf30dcc6b77bb9 # timeout=10
Commit message: "[docs] add jenkinsfiles"
> git rev-list --no-walk d24abcbc136a3f050b9c1aa365bf30dcc6b77bb9 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (publish)
[Pipeline] sh
+ git config --global user.email jiangtingqiang#gmail.com
[Pipeline] sh
+ git config --global user.name ****
[Pipeline] sh
+ git add -A
[Pipeline] sh
+ git diff-index --quiet HEAD
[Pipeline] sh
+ echo ****
****
[Pipeline] sh
+ echo
[Pipeline] sh
+ git push https://****:#github.com/****/xiaoqiang-blog-source.git
remote: Invalid username or password.
fatal: Authentication failed for 'https://****:#github.com/****/xiaoqiang-blog-source.git/'
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 128
Finished: FAILURE
am I missing something in configuration credentials?
Here I'm not answering how to use git. My answer is about secrets usage in jenkins only.
Which kind of secrets did you use? Secret text?
While using secrets - username and password, you can call separately username and password like this:
agent {
node {
label 'jenkins-master'
}
}
environment {
GITHUB_CRED = credentials('github-cred')
}
stages {
stage('publish') {
steps{
sh "echo ${GITHUB_CRED_USR}"
sh "echo ${GITHUB_CRED_PSW}"
sh "git push https://${GITHUB_CRED_USR}:${GITHUB_CRED_PSW}#github.com/jiangxiaoqiang/jiangxiaoqiang.github.io.git"
}
}
}
}
Also it make sence where do you store credentials: in global or project scope.
You can't use jenkins credentials as is.
Please review this stackoverflow answer explains how to run push from bash script.

Local Jenkins install has no Docker rights

I installed Docker (19.03.3) and Jenkins (2.190.2 LTS from https://jenkins.io/download/) on my Ubuntu 19.04 machine. Then I created a pipeline that loads a Jenkinsfile from an example Git repository I created. Everything works well until Jenkins instructs Docker to pull an image. The response is that the system does not have permission to do so. I already added my system user to the docker group (sudo usermod -aG docker $USER) and successfully tested docker pull node:6-alpine in my terminal. But Jenkins still fails.
Anyone an idea what the problem is? I guess this is not very complicated and rather a typical configuration error.
Jenkins Pipeline Console Output:
Started by user John Doe
Obtained Jenkinsfile from git http://repo.myserver.com/john/example-app.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/example-app-builder
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
using credential jenkins
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url http://repo.myserver.com/john/example-app.git # timeout=10
Fetching upstream changes from http://repo.myserver.com/john/example-app.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials Credentials for repo.myserver.com.
> git fetch --tags --force --progress -- http://repo.myserver.com/john/example-app.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision f578983d6e153b3063e184c8df194dcff6ee39ab (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f f578983d6e153b3063e184c8df194dcff6ee39ab # timeout=10
Commit message: "Add initial Jenkinsfile."
> git rev-list --no-walk f578983d6e153b3063e184c8df194dcff6ee39ab # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . node:6-alpine
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/node:6-alpine/json: dial unix /var/run/docker.sock: connect: permission denied
[Pipeline] isUnix
[Pipeline] sh
+ docker pull node:6-alpine
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/images/create?fromImage=node&tag=6-alpine: dial unix /var/run/docker.sock: connect: permission denied
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
Your Jenkins does not run with the dockers user. It runs with user jenkins. The command should therefore be the following in order to allow user jenkins to create Docker containers:
sudo usermod -aG docker jenkins

Jenkins Pipeline - ssh-agent can't find credentials

I have a task that's been working through the GUI as a Freestyle project. I'm trying to follow all of the instructions and documentation I can find to convert it to a Pipeline job, but I'm getting errors.
Here are the credentials I've created for the action.
I'm trying a fairly simple test to run a command on a remote Windows server.
#!/usr/bin/env groovy
pipeline {
agent any
stages {
stage("build") {
steps {
sshagent(credentials: ['1c0972a6-2bbf-4144-XXXX-XXXXXXXXXXXX']) {
sh """
ssh "dev user#XX.XX.XX.XX" su -c "powershell /project/getproj.bat | tee build.log"
"""
}
}
}
}
}
Finally, heres the output log.
Started by user XXXX XXXX
Obtained Jenkinsfile from git https://xx.xx.com/xxxx.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/Testing/xxxx
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
using credential 0d240009-1e30-4e3b-xxxx-xxxxxxxxxxxx
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://xx.xx.com/xxxx.git # timeout=10
Fetching upstream changes from https://xx.xx.com/xxxx.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials
> git fetch --tags --progress https://xx.xx.com/xxxx.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/convert_jenkinsfile^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/convert_jenkinsfile^{commit} # timeout=10
Checking out Revision 40a510567b52ce621cb6590ab233289cb1948ad4 (refs/remotes/origin/convert_jenkinsfile)
> git config core.sparsecheckout # timeout=10
> git checkout -f 40a510567b52ce621cb6590ab233289cb1948ad4
Commit message: "Update Jenkinsfile"
> git rev-list --no-walk 6325e08c341a4e7e0cec8538640bd3d6cf6941fa # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (build)
[Pipeline] sshagent
FATAL: [ssh-agent] Could not find specified credentials
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent] Exec ssh-agent (binary ssh-agent on a remote machine)
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-pRQqteq1L7US/agent.49961
SSH_AGENT_PID=49964
[ssh-agent] Started.
[Pipeline] {
[Pipeline] sh
+ ssh dev user#xx.xx.xx.xx su -c powershell /project/getproj.bat | tee build.log
Host key verification failed.
[Pipeline] }
$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 49964 killed;
[ssh-agent] Stopped.
[Pipeline] // sshagent
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 255
Finished: FAILURE
I can't tell if I'm doing something wrong with how I've identified the credentials, or there's something wrong in the Jenkinsfile. I'm intending to run multiple commands on the remote Windows server.
The ssh-agent plugin does not support user/password credentials.
It is not so easy to spot this information, but you can find that the plugin documentation says 'Note that only Private Key based credentials can be used.'
If you specify a credentials id referring to credentials of kind "Username with password", you always get "FATAL: [ssh-agent] Could not find specified credentials"
This might be related to JENKINS-32101. Please try the alternative syntax sshagent(['1c0972a6-2bbf-4144-XXXX-XXXXXXXXXXXX']) {...}.

Resources