简体   繁体   中英

Jenkins pipeline sh step fails

I'm learning Jenkins Pipelines and I'm trying to execute anything on a Linux build server but I get errors about it being unable to create a folder.

Here is the pipeline code

node('server') { 
    stage("Build-Release-Linux64-${NODE_NAME}") {   
        def ws = pwd()
        sh "ls -lha ${ws}"
    }
}

This is the error I get:

sh: 1: cannot create /opt/perforce/workspace/Dels-Testing-Area/MyStream-main@tmp/durable-07c26e68/pid; jsc=durable-8c9234a2eb6c2feded950bac03c8147a;JENKINS_SERVER_COOKIE=$jsc /opt/perforce/workspace/Dels-Testing-Area/MyStream-main@tmp/durable-07c26e68/script.sh: Directory nonexistent

I've checked the server while this is running and I can see that it does create the file "/opt/perforce/workspace/Dels-Testing-Area/MyStream-main@tmp/durable-07c26e68/script.sh"

The file contains the following and is being created by Jenkins and not myself:

#!/bin/sh -xe

It does not matter what I try to execute using the sh step, I get the same error.

Can anyone shed some light on why this is happening?

-= UPDATE =-

I'm currently using Jenkins 2.46.2 LTS and there are a number of updates available. I'm going to wait for a quite period and perform a full update and try this again in case it fixes anything.

I found out that the problem was because I had a single quote in my folder name. As soon as I removed the single quote it ran perfectly. This also links to this Jenkins issue [ https://issues.jenkins-ci.org/browse/JENKINS-44341] where I added a comment and voted for a fix.

So the fix is, only use the following characters in folder and job names [0-9a-zA-Z_-] excluding the square brackets and also don't use spaces.

I can confirm that using special characters and spaces in the "display name" field of a folder's configuration works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM