Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Self Releases Workflow (Nexus2)

Tips Migration To Global-JJB


Build docker image with local artifact


  • background: 
    • 1,for multicloud framework broker, openstack plugins, (might be applicable to other plugins), dockerfile is used to build docker image which will retrieve the artifact from nexus repo. The retrieve artifacts usually are *-snapshot which will be always the latest built artifacts.
    • 2, with global-jjb migration, xxx-maven-stage-master job will not push *-snapshot to nexus repo, instead the staging artifacts will be pushed to nexus as autorelease artifacts. There can be multiple staging artifacts tagged by different autorelease version, retrieve the latest artifacts requires explicitly autorelease version number , otherwise the retrieved staging artifacts will be the oldest image available.
    • the 2 practices above will make the docker building process problematic.
  • Resolution: build docker image with local built artifacts
    • It is recommended to change the dockerfile and pom file to build docker image with local built artifacts. This also remove the dockerfile's dependency over nexus repo.
  • Example:
    • 1, change pom file to copy dockerfile and local built artifacts to the same directory after maven package stage (and before maven deploy stage). Key point: change filtering extension for the artifacts' extension so that binary copy mode can be applied to copy artifacts.
      • <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
        <execution>
        <id>copy-resources</id>
        <phase>install</phase>
        <goals>
        <goal>copy-resources</goal>
        </goals>
        <configuration>
        <overwrite>true</overwrite>
        <nonFilteredFileExtensions>
        <nonFilteredFileExtension>zip</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
        <outputDirectory>${project.basedir}/docker_target</outputDirectory>
        <resources>
        <resource>
        <directory>${project.basedir}/docker</directory>
        <filtering>true</filtering>
        </resource>
        <resource>
        <directory>${project.basedir}/target</directory>
        <filtering>true</filtering>
        <includes>
        <include>*.zip</include>
        </includes>
        </resource>
        </resources>
        </configuration>
        </execution>
        </executions>
        </plugin>
    • 2, change dockerfile to copy the local built artifacts for image building
      • COPY ./multicloud-framework-broker-*.zip /opt/multicloud-framework.zip

  


Test the build locally:

$ mvn clean install -P docker -DCONTAINER_PUSH_REGISTRY=xxx

  • No labels