在 Jenkins slave 上使用 CURL 下载 zip 文件时无法创建文件
Failed to create the file while downloading zip file with CURL on Jenkins slave
我正在使用 Jenkins Pipline 和 Groovy 脚本在 jenkins 的从机上下载一个 zip。
以下是我的代码:
pipeline {
agent { label '<my slave label>' }
stage('Download') {
steps {
script {
def url = "<server url>"
def processDownload = ['bash', '-c', "curl -g -k --noproxy \"*\" -o <output-dir> \"${url}\""].execute()
processDownload.waitFor()
def processUnzip = ['bash', '-c', "7z e lwbs.zip"].execute()
processUnzip.waitFor()
}
}
}
}
我收到以下错误:
Warning: Failed to create the file Warning:
output-dir/newFile.zip: No such file or directory
我检查了以下内容:
- 当我在命令提示符下使用相同的
curl
命令时,它 运行 成功了。
- 我还确保授予适当的用户权限
允许詹金斯写入此目录。
- 目录存在,目录url
中没有space
- slave
上有足够的磁盘 space
- 服务器URL和证书正确
- 许多 SO 但 none 在
jenkins slave
上提到了问题
有什么我遗漏的吗?
感谢任何帮助。谢谢。
经过长时间的研究,我发现 bash 命令是使用以下命令触发的
def processDownload = ['bash', '-c', "curl -g -k --noproxy \"*\" -o <output-dir> \"${url}\""].execute()
Jenkins 将始终在 Master 上执行它。
当我将其更改为正常的 shell 命令时,Jenkins 会在从机上正确执行它。此外,为了解压缩,我使用了 Pipeline Utility Steps
插件,它提供了在 slave 上执行的解压缩功能。以下是我的工作代码:
stage('Download') {
steps {
script {
url = "<server url>"
sh "curl -k --noproxy \"*\" -o \"<output-dir>\" \"${url}\""
unzip(dir: '', glob: '', zipFile: 'fileName.zip')
}
}
}
我正在使用 Jenkins Pipline 和 Groovy 脚本在 jenkins 的从机上下载一个 zip。
以下是我的代码:
pipeline {
agent { label '<my slave label>' }
stage('Download') {
steps {
script {
def url = "<server url>"
def processDownload = ['bash', '-c', "curl -g -k --noproxy \"*\" -o <output-dir> \"${url}\""].execute()
processDownload.waitFor()
def processUnzip = ['bash', '-c', "7z e lwbs.zip"].execute()
processUnzip.waitFor()
}
}
}
}
我收到以下错误:
Warning: Failed to create the file Warning:
output-dir/newFile.zip: No such file or directory
我检查了以下内容:
- 当我在命令提示符下使用相同的
curl
命令时,它 运行 成功了。 - 我还确保授予适当的用户权限 允许詹金斯写入此目录。
- 目录存在,目录url 中没有space
- slave 上有足够的磁盘 space
- 服务器URL和证书正确
- 许多 SO 但 none 在
jenkins slave
上提到了问题
有什么我遗漏的吗?
感谢任何帮助。谢谢。
经过长时间的研究,我发现 bash 命令是使用以下命令触发的
def processDownload = ['bash', '-c', "curl -g -k --noproxy \"*\" -o <output-dir> \"${url}\""].execute()
Jenkins 将始终在 Master 上执行它。
当我将其更改为正常的 shell 命令时,Jenkins 会在从机上正确执行它。此外,为了解压缩,我使用了 Pipeline Utility Steps
插件,它提供了在 slave 上执行的解压缩功能。以下是我的工作代码:
stage('Download') {
steps {
script {
url = "<server url>"
sh "curl -k --noproxy \"*\" -o \"<output-dir>\" \"${url}\""
unzip(dir: '', glob: '', zipFile: 'fileName.zip')
}
}
}