Jenkins“Docker 构建和发布”插件不起作用

2024-01-11

我尝试在 Windows 10 机器中使用 Jenkins“Docker Build and Publish”插件构建 docker 映像。为此,我从 docker 中提取了 jenkins 映像。我的要求是,在 jenkins 映像之上,我需要创建一项作业[来自 GIT 的 SCM -> 构建 Maven jar -> 使用 DockerFile,尝试构建 docker 映像并将其推送到 dockerhub]。

First inside Jenkins-> Manage Jenkins ->Global tool configuration ->Add docker enter image description here

后来我尝试创建詹金斯自由式工作。在其中我添加了我的 GITlab 项目 url 和凭据。

In Build section, first i configured Maven enter image description here

“Docker 构建和发布”部分中的第二个,

存储库名称作为我的 dockerhub 存储库名称

DOCKER HOST URI - 来自命令“docker-machine env 'docker-machine-name'”的 Docker 主机地址

And then i clicked Advanced tab in BUILD section, added docker( the one which i add in Jenkins-> Manage Jenkins ->Global tool configuration ->Add docker) enter image description here

每当我运行 jenkins 作业时,它都会从 GITLab 中提取代码,然后 Maven 成功创建 jar。在我尝试使用 Dockerfile 构建 docker 镜像之后。

我的 Docker 文件:

詹金斯作业错误日志是

[Sample] $ /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/maven/bin/mvn clean package -DskipTests=true
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------------< com.example:sample >-------------------------
[INFO] Building sample 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ sample ---
[INFO] Deleting /var/jenkins_home/workspace/Sample/target
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ sample ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /var/jenkins_home/workspace/Sample/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/jenkins_home/workspace/Sample/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ sample ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /var/jenkins_home/workspace/Sample/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ sample ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ sample ---
[INFO] Building jar: /var/jenkins_home/workspace/Sample/target/demo.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.2.2.RELEASE:repackage (repackage) @ sample ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  13.898 s
[INFO] Finished at: 2020-01-24T13:32:52Z
[INFO] ------------------------------------------------------------------------
[Sample] $ /var/jenkins_home/tools/org.jenkinsci.plugins.docker.commons.tools.DockerTool/docker/bin/docker build -t karthickas/springboot --file=Dockerfile .
error during connect: Post http://10.5.54.173:2376/v1.29/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&t=karthickas%2Fspringboot&target=&ulimits=null: EOF
Build step 'Docker Build and Publish' marked build as failure
Finished: FAILURE

在调试时,我在浏览器中尝试了 docker 主机 uri,出现错误“客户端向 HTTPS 服务器发送了 HTTP 请求。”

我错过了什么。请帮我解决这个问题

NOTE: I tried to build docker image & push that to dockerhub using command prompt. Successfully i can create and push to dockerhub. enter image description here


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Jenkins“Docker 构建和发布”插件不起作用 的相关文章

随机推荐