Tag: maven

如何正确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> […]

Maven:构build儿童项目的Docker镜像

我的项目有以下结构: pom.xml | x—-child1 | | | x—-pom.xml | x—-child2 | x—-pom.xml 有一个pom父亲和两个孩子poms。 孩子的构build使用Spotify插件来生成项目的Docker镜像。 我的问题是,我怎样才能从根目录调用两个构build? 我基本上需要调用在子模块上构build的spotify插件。 我试图使用 mvn clean install 但是孩子是用maven-compiler-plugin构build的,而不是用docker-maven-plugin构build的。 这是我在孩子身上使用的版本: <build> <plugins> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>${spotify.plugin.version}</version> <configuration> <imageName>childImage</imageName> <dockerDirectory>${project.build.directory}/../src/docker</dockerDirectory> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> </plugins> </build> 在爸爸,我已经定义了这样的模块。 <modules> <module>child1</module> <module>child2</module> </modules> 感谢您的build议!

如何使用docker.image提供托pipe文件到Jenkins版本?

我正在尝试使用Jenkinspipe道来构build一个Maven Java项目,并将其构件部署到Nexus中。 Nexus凭证由Jenkinspipe理,所以我需要Jenkins提供Maven settings.xml文件。 我的pipe道使用docker运行构build。 我的Jenkinsfile如下所示: node('docker') { git 'git@bitbucket.org:myorg/myproject.git' stage 'Build and Test' // This throws: java.lang.UnsupportedOperationException: Refusing to marshal org.codehaus.groovy.runtime.InvokerInvocationException for security reasons //configFileProvider([configFile(fileId: '7d6efcd2-ff3d-43dc-be40-898dab2bff64', variable: 'MYSETTINGS')]) { // sh 'cp ${MYSETTINGS} mysettings.xml' // } docker.image('maven:3.3.9').inside { // sh 'mvn -s mysettings.xml -U -e clean deploy' // This fails trying to access AWS […]

由于NoClassDefFoundError,无法启动embedded容器

我的SpringBoot应用程序与Eclipse IDE很好地工作,但是当我在Docker Container上运行我的应用程序时,它的图像生成良好,但是当我运行图像时,它将得到ClassDefnotfoundexception并且无法启动embedded容器。 How can I fix it?` In Dockerfile FROM java:8 EXPOSE 8080 ADD /target/docker.ras.jar docker.ras.jar RUN sh -c 'touch /docker.ras.jar ENTRYPOINT ["java","-jar","docker.ras.jar"] In pom.xml i also use maven plugin <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>example.docker.ras</groupId> <artifactId>docker.ras</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.3.RELEASE</version> </parent> <name>docker.ras</name> <url>http://maven.apache.org</url> <properties> <java.version>1.8</java.version> <start-class>docker.ras.App</start-class> <docker.image.prefix>springio</docker.image.prefix> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> […]

在Windows中fabric8io docker-maven-plugin

我正在尝试使用maven,docker和Cassandra进行一些集成testing。 现在,我写了一个虚拟代码来查询Cassandra并试图运行Cassandra容器。 这是关于插件的pom.xml: <plugin> <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.14.1</version> <configuration> <images> <image> <alias>some-cassandra</alias> <name>cassandra:3.0</name> <run> <ports> <!–<port>cassandra.port:9042</port>–> <port>9042:9042</port> <port>9160:9160</port> <port>7199:7199</port> <port>7001:7001</port> </ports> <wait> <log>database system is ready to accept connections</log> <time>30000</time> </wait> </run> </image> </images> </configuration> <executions> <execution> <id>start</id> <phase>pre-integration-test</phase> <goals> <!– "build" should be used to create the images with the artifact –> <goal>start</goal> </goals> </execution> […]

在docker throw中用maven构build{} – > unix:// localhost:80:没有这样的文件或者导演

我有一个问题,因为我没有以前没有几天。 当我启动./mvnw -Pprod package -DskipTests=true docker:build在我的容器我有这个日志 [INFO] Copying src/main/docker/app.yml -> /home/jhipster/app/target/docker/app.yml [INFO] Copying src/main/docker/Dockerfile -> /home/jhipster/app/target/docker/Dockerfile [INFO] Copying src/main/docker/postgresql.yml -> /home/jhipster/app/target/docker/postgresql.yml [INFO] Copying src/main/docker/sonar.yml -> /home/jhipster/app/target/docker/sonar.yml [INFO] Building image projectName May 03, 2017 8:50:21 PM org.apache.http.impl.execchain.RetryExec execute INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: No such file or directory May 03, 2017 […]

高级Docker和Dockerfile卷/书写理解

我正在开发一个Maven项目,并在这个项目中使用Junit进行testing。 我是新来的docker,我想写一个Dockerfile,生成一个图像,创build一个容器,运行时,执行testing,并输出在target/failsafe-reportsfind的XML结果(Maven插件的输出文件夹总结了Junittesting的结果)。 我一直在尝试使用像Dockerfile参考和pipe理容器中的数据的链接。 我的导师编写了一个使用docker run -it –rm –name containerName -v "$PWD":/usr/src/tests -v /Users/theUser/.m2:/root/.m2 -w /usr/src/tests maven:3.5-alpine mvn clean verify来实现这一点的命令行docker run -it –rm –name containerName -v "$PWD":/usr/src/tests -v /Users/theUser/.m2:/root/.m2 -w /usr/src/tests maven:3.5-alpine mvn clean verify 。 上面的行在我的项目的根目录中(在pom和Dockerfile所在的位置)被调用,所以$PWD引用了我的项目的根目录。 我的问题是在Dockerfile中可以自动完成多less工作? 在我使用和运行Dockerfile的尝试中,我没有能够得到任何写有当前Dockerfile的东西。 FROM maven:3.5-alpine COPY ["./", "/usr/local/tests"] VOLUME /usr/local/tests/target/failsafe-reports ENTRYPOINT mvn -f /usr/local/tests/pom.xml verify 我用docker build . -t imageName构build它docker […]

如何在Jenkinspipe道中使用嵌套的docker.image('test_image')。inside()

我有一个jenkins容器,它触发一个maven容器来构build一个java代码。 现在我想用seleniumtesting相同的代码。 我有另一个selenium服务器的容器。 但是使用selenium运行testing的命令是需要Maven的mvn命令。 因为我在selenium容器内执行这个,mvn不被识别。 我如何使用selenium容器内的Maven容器? 是否可以嵌套? 我不想在同一个容器中安装所有的东西。 这是Jenkinsfile: node { stage('checkout') { git credentialsId: 'Gitlab_cred', url: 'urlhere' } stage('Build') { docker.image('mvn_custom_image').inside('-u root'){ //mvn commands to build the project } } stage('Archive and Packaging') { archiveArtifacts '**/*.war' } stage('Integration Test') { docker.image('selenium/node-firefox:3.4.0-dysprosium').inside{ //I want to run mvn command using selenium here // This image doesn't […]

为弹簧引导微服务configurationDocker容器

我是新的docker工人,我想知道如何在使用docker撰写yml文件时在maven本地安装依赖项。 就像我有3个微服务和那些我在docker-compose.yml文件中configuration的服务,但是我想要使用Maven安装在本地maven中安装一个依赖项,这样我就可以通过导入在其他微服务中使用这个依赖项。 这可能吗 ? 提前致谢。

Docker多阶段构build和安装/前一阶段共享

我想使用多阶段构build来避免每次构build应用程序时都下载我的Java项目所需的所有Maven依赖项。 我正在考虑在第一阶段解决Maven依赖关系,然后在第二阶段构build应用程序,这需要访问前一阶段下载的依赖项。 如果我能很好地理解多阶段构build,我可以将在第一阶段创build的文件复制到第二阶段,但理想情况下,我希望能够从依赖项所在的第一个阶段“挂载”或“共享”文件夹,而不是复制文件,这有可能吗? 还是有更好的方法来实现这一目标? 谢谢。 编辑: 这是我想到的第一个阶段 FROM some-image-with-maven AS maven-repo WORKDIR /workspace/ COPY pom.xml . RUN mvn -B -f pom.xml dependency:resolve 但是由于pom文件在大多数情况下是不同的(因为我想在项目中共享这个阶段),下面的解决依赖关系的步骤将再次下载它们(而不是使用caching层)。