简体   繁体   English

詹金斯管道sh步骤失败

[英]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. 我正在学习Jenkins Pipelines,并且尝试在Linux构建服务器上执行任何操作,但是由于无法创建文件夹而收到错误消息。

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" 我在服务器运行时检查了服务器,可以看到它确实创建了文件“ /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: 该文件包含以下内容,由Jenkins(而非我自己)创建:

#!/bin/sh -xe

It does not matter what I try to execute using the sh step, I get the same error. 尝试使用sh步骤执行什么都没有关系,我会遇到相同的错误。

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. 我当前正在使用Jenkins 2.46.2 LTS,并且有许多可用的更新。 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. 这也链接到Jenkins问题[ https://issues.jenkins-ci.org/browse/JENKINS-44341] ,我在其中添加了评论并投票决定要解决的问题。

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. 因此,解决方法是,仅在文件夹和作业名称[0-9a-zA-Z_-]中使用以下字符(不包括方括号),也不要使用空格。

I can confirm that using special characters and spaces in the "display name" field of a folder's configuration works fine. 我可以确认在文件夹配置的“显示名称”字段中使用特殊字符和空格可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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