MultiCloud CICD practices

Self Releasing process

Self Releases Workflow (Nexus2)

1, ensure your jjb will build and push the appropriate docker image to nexus3.onap.org , e.g. https://gerrit.onap.org/r/c/multicloud/openstack/+/103211

2, ensure jjb has executed recently, if not , you can trigger it by replying message ‘stage-release’ to one of patch to multicloud/k8s over gerrit.onap.org , example: https://gerrit.onap.org/r/c/multicloud/openstack/+/104344 , then wait and locate the jjb execution record under the message from the gerrit.onap.org, e.g. https://jenkins.onap.org/job/multicloud-openstack-maven-docker-stage-master/310/
Bin Yang
Patch Set 1:

stage-release

Apr 02 4:45 PM
ONAP Jobbuilder
Patch Set 1:

Build Successful

https://jenkins.onap.org/job/multicloud-openstack-maven-docker-stage-master/310/ : SUCCESS

Logs: https://logs.onap.org/production/vex-yul-ecomp-jenkins-1/multicloud-openstack-maven-docker-stage-master/310

https://jenkins.onap.org/job/multicloud-openstack-maven-stage-master/381/ : SUCCESS

Logs: https://logs.onap.org/production/vex-yul-ecomp-jenkins-1/multicloud-openstack-maven-stage-master/381

3, you should be able to find out following info from the Jenkins jjb page:

Success Build #310 (Apr 2, 2020 8:49:51 AM)
Build logs: https://logs.onap.org/production/vex-yul-ecomp-jenkins-1/multicloud-openstack-maven-docker-stage-master/310
No changes.

Triggered by Gerrit: https://gerrit.onap.org/r/c/multicloud/openstack/+/104344

Other triggered builds for this event.
multicloud-openstack-maven-stage-master #381

This run spent:

3 min 53 sec waiting;
21 min build duration;
25 min total from scheduled to completion.
Revision: 4317682484a28f10d4590ae9569715dd46f181b3
refs/remotes/origin/master

4, create container yaml for releasing the docker image: e.g. https://gerrit.onap.org/r/c/multicloud/openstack/+/104966

One verified, merge it and the docker image releasing jjb will be triggered:

ONAP Jobbuilder
Patch Set 2:

Build Successful

https://jenkins.onap.org/job/multicloud-openstack-release-merge/12/ : SUCCESS

Logs: https://logs.onap.org/production/vex-yul-ecomp-jenkins-1/multicloud-openstack-release-merge/12

Once the jjb is done successfully, your docker image should be pushed to nexus3.onap.org

https://nexus3.onap.org/#browse/search=keyword%3Dmulticloud%2Fstarlingx:912d0fe7b81923925b23d1923e504294


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