maven - I want to get the artifact version deployed by Jenkins -


i run maven deploy step (using maven build step) , artifact deployed timestamp.

i want create docker image has deployed artifact , docker image tagged artifact timestamp. common scenario tag of docker image has same artifact contains.

i have read couple of posts

  1. jenkins maven deploy jar nexus - artifact naming
  2. jenkins - how can pass parameters upstream downstream
  3. sonatype nexus rest api fetch latest build version

where [3] gives me list of snapshot-versions server in xml, has parsed.

  • since i'm pushing artifact in jenkins job, possible know full artifact name in build instead of getting server.

  • is there api/any other way, can give name of latest artifact instead of artifact xml

the -snapshot part of files (attached on maven deployment 'task') replaced timestamped version @ deploy:deploy phase.

1) create docker image file

extend artifact pom docker-maven-plugin (provided spotify @ https://github.com/spotify/docker-maven-plugin) .

[...]

you can bind build goal package phase, container built when run mvn package.

[...]

<plugin>   <groupid>com.spotify</groupid>   <artifactid>docker-maven-plugin</artifactid>   <version>0.2.11</version>   <executions>     <execution>       <phase>package</phase>       <goals>         <goal>build</goal>       </goals>       <configuration>         <imagename>${project.build.finalname}</imagename>         <baseimage>java</baseimage>         <entrypoint>["java", "-jar", "/${project.build.finalname}.jar"]</entrypoint>         <!-- copy service's jar file target root directory of image -->          <resources>            <resource>              <targetpath>/</targetpath>              <directory>${project.build.directory}</directory>              <include>${project.build.finalname}.jar</include>            </resource>         </resources>       </configuration>     </execution>   </executions> </plugin> 

the docker image name defined @ <imagename /> , use artifact file name (${project.build.finalname}).

imagename: built image given name.

more information build goal: mvn com.spotify:docker-maven-plugin:help -ddetail=true -dgoal=build or https://github.com/spotify/docker-maven-plugin

2) attach docker image file on maven deploy task

attach - if docker-maven-plugin doesn't - docker image file build-helper-maven-plugin (http://www.mojohaus.org/build-helper-maven-plugin/usage.html).

  <plugin>     <groupid>org.codehaus.mojo</groupid>     <artifactid>build-helper-maven-plugin</artifactid>     <version>1.9.1</version>     <executions>       <execution>         <id>attach-artifacts</id>         <phase>package</phase>         <goals>           <goal>attach-artifact</goal>         </goals>         <configuration>           <artifacts>             <artifact>               <file>${project.build.finalname}</file>               <type>...</type>               <classifier>docker</classifier>             </artifact>             ...           </artifacts>         </configuration>       </execution>     </executions>   </plugin> 

after these steps artifact files , docker image artifact deployed maven repository identical version strings.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -