cas*_*sen 3 jenkins docker dockerfile jenkins-declarative-pipeline
我正在使用 Jenkins 声明性管道和 Docker-for-Windows 代理通过Dockerfile.
注意:不幸的是,目前不是使用基于 Linux 的 docker 守护程序的解决方案,因为我需要运行 Windows 二进制文件。
设置: Jenkins master 通过 Docker 在 Linux 16.04 上运行。詹金斯构建代理是
Docker 18.x 在尝试使用 Windows Containers 时让我头疼,所以我回滚到 17.x。当我尝试与 Jenkins 一起运行并且 nohup 不在路径上时,我仍然遇到了一些问题,但是通过将 Git 二进制文件添加到 Windows 搜索路径(另一个参考)解决了这个问题。我怀疑我当前的问题可能与此有关。
代码:我正在尝试初始化 aJenkinsfile并在其中运行一个简单的 hello-world-printout。
/詹金斯档案
pipeline {
agent none
stages {
stage('Docker Test') {
agent {
dockerfile {
filename 'Dockerfile'
label 'windocker'
}
}
steps {
println 'Hello, World!'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
/Dockerfile
FROM python:3.7-windowsservercore
RUN python -m pip install --upgrade pip
Run Code Online (Sandbox Code Playgroud)
基本上,这应该是一个干净的图像,只需打印“Hello, World!”。但它在 Jenkins 上失败了!
日志输出:
[C:\jenkins\workspace\dockerfilecd4c215a] Running shell script
+ docker build -t cbe5e0bb1fa45f7ec37a2b15566f84aa9bd08f5d -f Dockerfile .
Sending build context to Docker daemon 337.4kB
Step 1/2 : FROM python:3.7-windowsservercore
---> 340689b75c39
Step 2/2 : RUN python -m pip install --upgrade pip
---> Using cache
---> a93f446a877f
Successfully built a93f446a877f
Successfully tagged cbe5e0bb1fa45f7ec37a2b15566f84aa9bd08f5d:latest
[C:\jenkins\workspace\dockerfilecd4c215a] Running shell script
+ docker inspect -f . cbe5e0bb1fa45f7ec37a2b15566f84aa9bd08f5d
.
Cannot run program "id": CreateProcess error=2, The system cannot find the file specified
Run Code Online (Sandbox Code Playgroud)
小智 5
问题是,目前不支持 windows。它正在调用 linux "id" 命令来获取当前用户 ID。
Jenkins 有一个开放的 Pull Request 和 JIRA Ticket 来支持 Windows docker 管道:
| 归档时间: |
|
| 查看次数: |
2993 次 |
| 最近记录: |