如何使用Jenkins构建和推送Docker映像?
我具有在安装了Windows docker的Windows 10 Jenkins从站上执行的以下管道。
node("windows_10_pro_n_vs2017") {
checkout scm
def app
stage('Build image') {
/* This builds the actual image; synonymous to
* docker build on the command line */
app = docker.build("simmarn/emma2html:win -f docker-windows/Dockerfile .")
}
stage('Push image') {
/* Finally, we'll push the image with two tags:
* First, the incremental build number from Jenkins
* Second, the 'win' tag.
* Pushing multiple tags is cheap, as all the layers are reused. */
docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') {
app.push("${env.BUILD_NUMBER}")
app.push("win")
}
}
}
但是在没有任何有用信息的情况下构建失败:
Started by user ...
23:32:31 Connecting to https://api.github.com using .../****** (GitHub Access Token)
Obtained Jenkinsfile from ...
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on win1 in C:\jenkins\workspace\emma2html_master
[Pipeline] {
[Pipeline] checkout
using credential github
....
[Pipeline] stage
[Pipeline] { (Build image)
[Pipeline] sh
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
我猜docker.build和docker.withRegistry适用于Linux docker。 Windows docker是否可以改编?
我在Blue Ocean上遇到以下错误:
无法运行程序“ nohup”(在目录“ C:\ jenkins \ workspace \ emma2html_master”中):CreateProcess error = 2,系统找不到指定的文件
/马丁
答案 0 :(得分:0)
对不起,我只需要更新docker-pipeline插件即可使其正常工作。