如何正确build立jenkins的maven / docker?
我有一个spring boot maven项目,需要构build一个docker镜像:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <configuration> <imageName>${docker.image.prefix}/${project.artifactId}</imageName> <dockerDirectory>src/main/docker</dockerDirectory> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> <executions> <execution> <id>build-image</id> <phase>package</phase> <goals> <goal>build</goal> </goals> </execution> <execution> <id>tag-image</id> <phase>package</phase> <goals> <goal>tag</goal> </goals> <configuration> <image>api</image> <newName>registry.example.com/api</newName> </configuration> </execution> </executions> </plugin> </plugins> <resources> <resource> <directory>${basedir}/src/main/docker</directory> <filtering>true</filtering> <includes> <include>Dockerfile</include> </includes> </resource> </resources> </build>
作为用户“eugene”我可以运行下面的命令没有任何问题:
mvn -X package docker:build
我在我的Mac上本地安装了Jenkins,并创build了一个运行Maven目标的工作:
package docker:build
jenkins生成失败与以下控制台输出:
Started by user eugene Building in workspace /Users/Shared/Jenkins/Home/jobs/test_2/workspace [WS-CLEANUP] Deleting project workspace... [WS-CLEANUP] Done Cloning the remote Git repository Cloning repository http://eugene@localhost:7990/scm/test/test_01.git > git init /Users/Shared/Jenkins/Home/jobs/test_2/workspace # timeout=10 Fetching upstream changes from http://eugene@localhost:7990/scm/test/test_01.git > git --version # timeout=10 > git fetch --tags --progress http://eugene@localhost:7990/scm/test/test_01.git +refs/heads/*:refs/remotes/origin/* > git config remote.origin.url http://eugene@localhost:7990/scm/test/test_01.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url http://eugene@localhost:7990/scm/test/test_01.git # timeout=10 Fetching upstream changes from http://eugene@localhost:7990/scm/test/test_01.git > git fetch --tags --progress http://eugene@localhost:7990/scm/test/test_01.git +refs/heads/*:refs/remotes/origin/* > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 Checking out Revision 0dd6cdb03e3cbf01918ed160b54ff85c44cdbf6f (refs/remotes/origin/master) > git config core.sparsecheckout # timeout=10 > git checkout -f 0dd6cdb03e3cbf01918ed160b54ff85c44cdbf6f > git rev-list 0dd6cdb03e3cbf01918ed160b54ff85c44cdbf6f # timeout=10 [workspace] $ mvn package docker:build FATAL: command execution failed java.io.IOException: Cannot run program "mvn" (in directory "/Users/Shared/Jenkins/Home/jobs/test_2/workspace"): error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at hudson.Proc$LocalProc.<init>(Proc.java:243) at hudson.Proc$LocalProc.<init>(Proc.java:212) at hudson.Launcher$LocalLauncher.launch(Launcher.java:815) at hudson.Launcher$ProcStarter.start(Launcher.java:381) at hudson.Launcher$ProcStarter.join(Launcher.java:388) at hudson.tasks.Maven.perform(Maven.java:363) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779) at hudson.model.Build$BuildExecution.build(Build.java:205) at hudson.model.Build$BuildExecution.doRun(Build.java:162) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534) at hudson.model.Run.execute(Run.java:1720) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:404) Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:248) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 15 more Build step 'Invoke top-level Maven targets' marked build as failure Finished: FAILURE
我能做些什么来解决这个问题,并让Jenkinsbuild立我的应用程序的docker形象?
- 从docker容器发送lan包的唤醒
- 从另一个Docker实例运行Zaleniumtesting
- Docker返回“json:can not unmarshal string into Go value of type string”
- 将spark-jobserver部署到BlueMix Spark节点
- Cassandra节点不在Docker中链接
- docker是一个可能的解决scheme,以rubyGIL限制在轨道?
- EC2代理的Mesos / Marathon主机名不可访问
- Docker – 如何将新的python依赖关系添加到现有的docker镜像?
- 是否有可能在docker中运行android模拟器/ android应用程序?