Skip to content
标签
欢迎扫码关注公众号

Jenkins Pipeline 中调用 Shell 脚本 Permission denied

Jenkinspipeline 脚本中通过 sh 命令运行脚本时报了 Permission denied 错误。

pipeline 脚本和 shell 脚本 都是从 git 上获取的,通过 ls -l 命令查看,发现默认给予的是 644 权限,没有运行权限。

所以需要在 pipeline 脚本中使用 chmod 命令给相应的文件赋权限。

修改后示例如下:

groovy
pipeline {
    agent any

    stages {
        stage('Shell') {
            steps {
                sh 'chmod 744 ${WORKSPACE}@script/shell-script.sh'
                sh '${WORKSPACE}@script/shell-script.sh
            }
        }
    }
}

其中 ${WORKSPACE}Jenkins 的环境变量,表示当前 Job 的工作目录。

通过 Git 获取的 pipeline 脚本默认会放在 ${WORKSPACE}@script 目录下面。

需要注意的是在 Job 的设置页面需要 取消 勾选 轻量级检出 选项,否则仅会获取 pipeline 脚本。

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.