Jenkins Pipeline "yarn install" command not found - jenkins

This is my first Jenkins script, it currently operates well on Linux but I migrate to MacOS (High Sierra) with the result of getting shell script error.
Node and yarn packages are installed on local Jenkins user. I can't figure out why this error just happens, could anyone give me a hand on this?
Here is my Jenkins file:
node {
stage('Check out') {
checkout scm
}
stage('Prepare') {
sh "yarn install"
}
stage('Test') {
sh "yarn test"
}
stage('Sonar') {
if (env.BRANCH_NAME == 'dev') {
def scannerHome = tool 'sonar scanner';
withSonarQubeEnv('sonar') {
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
}
And full log:
14:43:11 Connecting to https://api.github.com using hariklee/******
Obtained Jenkinsfile from 6c639bd70ac86cbe6a49ac0b58bcc10e3c64a375
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in
/Users/Shared/Jenkins/Home/workspace/wingman_423_ci_cd-7PSSGRAMBTXUQRESYCNVODXU7IZJLJLPHQOE3KYEPCSAAYAFFD4A
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Check out)
[Pipeline] checkout
git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://github.com/wingman-xyz/app.git # timeout=10
Fetching without tags
Fetching upstream changes from https://github.com/wingman-xyz/app.git
git --version # timeout=10
using GIT_ASKPASS to set credentials
git fetch --no-tags --progress https://github.com/wingman-xyz/app.git +refs/heads/423_ci_cd:refs/remotes/origin/423_ci_cd
Checking out Revision 6c639bd70ac86cbe6a49ac0b58bcc10e3c64a375 (423_ci_cd)
git config core.sparsecheckout # timeout=10
git checkout -f 6c639bd70ac86cbe6a49ac0b58bcc10e3c64a375
Commit message: "jenkins test"
First time build. Skipping changelog.
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Prepare)
[Pipeline] sh
[wingman_423_ci_cd-7PSSGRAMBTXUQRESYCNVODXU7IZJLJLPHQOE3KYEPCSAAYAFFD4A] Running shell script
yarn install
/Users/Shared/Jenkins/Home/workspace/wingman_423_ci_cd-7PSSGRAMBTXUQRESYCNVODXU7IZJLJLPHQOE3KYEPCSAAYAFFD4A#tmp/durable-cf573520/script.sh: line 2: yarn: command not found
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
GitHub has been notified of this commit’s build result
ERROR: script returned exit code 127
Finished: FAILURE

There is no yarn command in your PATH variable.
Do npm install -g yarn before
stage('Prepare') {
sh "npm install -g yarn"
sh "yarn install"
}
If you get an error about not found npm command then you will have to add npm explicitly to your PATH using withEnv() {}
withEnv(['PATH+NODE=/something=/path/to/node/bin']) {
stage('Prepare') {
sh "npm install -g yarn"
sh "yarn install"
}
}

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 Pipeline failed

I am running a scripted version of the Jenkins pipeline. It ran through all the stages except the last stage. It failed every time.
Here is the Jenkins code that keep on failing:
stage('Deploy Production') {
echo "Deploy Prod on: ${env.BRANCH_NAME}"
try {
if (env.BRANCH_NAME == 'master'){
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'XX',
usernameVariable: 'XXXXX', passwordVariable: 'XXXXXX']]) {
sh 'npm run build-prod-ci'
sh 'cf login -u ${XXXXX} -p ${XXXXXX} -a website.com -o XXX -s XXXX'
sh 'cf blue-green-deploy Dashboard'
sh 'cf delete Dashboard-old -f'
}
}
} finally {
deleteDir()
sh 'cf logout'
}
}
This is the printout and the error message. Any help in resolving this issue is appreciated.
Plugin blue-green-deploy 1.3.0 successfully installed.
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy Development)
[Pipeline] echo
Deploy Dev on: master
[Pipeline] deleteDir
[Pipeline] sh
+ cf logout
Logging out ...
OK
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy Production)
[Pipeline] echo
Deploy Prod on: master
[Pipeline] withCredentials
Masking supported pattern matches of $XXXXXX
[Pipeline] {
[Pipeline] sh
+ npm run build-prod-ci
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /v/wl/ws/Dashboard_master/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/v/wl/ws/Dashboard_master/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /v/wl/wsp/Dashboard_master/.npm/_logs/2022-07-06T22_43_57_239Z-debug.log
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] deleteDir
[Pipeline] sh
+ cf logout
Logging out ...
OK
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timeout
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 254
Previous stages with npm commands worked fine. Here is an example of a stage that worked:
stage('Run project tests and build') {
echo "Run project tests and build on: ${env.BRANCH_NAME}"
sh "npm run lint"
//sh "npm run compodoc-ci"
//sh "npm run test-coverage"
sh "npm run build-dev-ci"
}
This issue was self inflicted, and the comments that was given above gave me some hints to arrive at the solution.
The problem was that I was moving the original Jenkins code (I think it's called Declarative Pipeline) over to this form (scripted pipeline?), and I converted the code below without thinking because Jenkins is not something I work with everyday...
steps {
when {
branch 'dev'
}
}
post {
always {
deleteDir()
to
try {
if (env.BRANCH_NAME == 'dev'){
} finally {
deleteDir()
Anyway, the command deleteDir() delete the directory, and therefore it can't find that file anymore.
Thanks for the help guys. Much appreciated.
Lesson: check your code to understand what's it's doing. Copy and paste will only help to a certain extent.

Jenkins fails to build with 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
}
}

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

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