我正在尝试使用 docker 代理在 Windows 10 下运行一个简单的 jenkins 管道。我的环境:
- 从 cli (java -jar jenkins) 运行最新的 Jenkins
- 路径中的 Git.exe 和 docker.exe 均正常运行。
我的 Jenkins 文件:
pipeline {
agent {
docker {
image 'maven:3.5.0'
}
}
stages {
stage('Hello') {
steps {
sh 'mvn --version'
}
}
}
}
结果是它甚至从未尝试运行 docker:
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Agent Setup)
[Pipeline] sh
[C:\Users\amoya\.jenkins\workspace\oya_sampleapp_jenkins-setup-FIF55WR7GZ32BUQR22LYEG2ZKBHHCXBCQH76TBZYJSB3TNTZCV7A] Running shell script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
完整输出:https://gist.github.com/adrianmoya/bf01d97090c4b9de7fd27db31ecfc837
这就像尝试在 Windows 中运行 sh,完全忽略 docker 代理设置。在 linux 下它拉下图像并成功运行。任何帮助表示赞赏
最佳答案
你在哪里运行 docker 守护进程?
如果它在本地主机上,请尝试将全局 DOCKER_HOST 环境变量设置为 tcp://ip.of.docker.daemon:port
您也可以在 Jenkins 配置中手动设置
此外,它似乎试图在 Windows 中启动 shell 命令,但没有取得太大成功……也许您可以尝试使用“batch”而不是“sh”? (虽然这在非 Windows 容器中运行 shell 的上下文中没有意义)
另一种选择是在 Virtualbox 或 Hyper-V 中运行 Jenkins 节点来完成所有 docker 构建/运行,并使用节点标签。
关于windows - Windows下如何使用docker agent设置jenkins blue ocean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43957848/