Define CMake + Package Cloud stage job 87/2987/7
authorLott, Christopher (cl778h) <cl778h@att.com>
Wed, 25 Mar 2020 20:33:06 +0000 (16:33 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Thu, 26 Mar 2020 18:55:48 +0000 (14:55 -0400)
On "stage-release" comment, build deb/rpm packages with CMake/Make
then publish them to PackageCloud.io.  First use is in the
ric-plt/xapp-frame-cpp project.

Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
Change-Id: Iaab8d8c8bc7ef7cf0e066c55ff73cea7d46b954e

jjb/oran-templates/oran-c-cpp-jobs.yaml [new file with mode: 0644]
jjb/oran-templates/oran-docker-ci-jobs.yaml
jjb/oran-templates/oran-package-cloud-macros.yaml [new file with mode: 0644]
jjb/ric-plt-xapp-frame-cpp/ric-plt-xapp-frame-cpp.yaml

diff --git a/jjb/oran-templates/oran-c-cpp-jobs.yaml b/jjb/oran-templates/oran-c-cpp-jobs.yaml
new file mode 100644 (file)
index 0000000..386b513
--- /dev/null
@@ -0,0 +1,149 @@
+#   Copyright (c) 2020 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the 'License');
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an 'AS IS' BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+---
+
+# This file is structured with a cmake alias/anchor, an alias/anchor,
+# and a job-template to simplify the task of lifting it to global-jjb.
+
+####################
+# COMMON FUNCTIONS #
+####################
+
+# Clone of lf_cmake_common which isn't visible here
+- oran_cmake_common: &oran_cmake_common
+    name: oran-cmake-common
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    project-type: freestyle
+    node: "{build-node}"
+    disabled: "{disable-job}"
+
+    properties:
+      - lf-infra-properties:
+          build-days-to-keep: "{build-days-to-keep}"
+
+    parameters:
+      - lf-infra-parameters:
+          project: "{project}"
+          branch: "{branch}"
+          stream: "{stream}"
+      - lf-cmake-parameters:
+          build-dir: "{build-dir}"
+          cmake-opts: "{cmake-opts}"
+          install-prefix: "{install-prefix}"
+          make-opts: "{make-opts}"
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: "{build-timeout}"
+          jenkins-ssh-credential: "{jenkins-ssh-credential}"
+
+    publishers:
+      - lf-infra-publish
+
+##################
+# CMAKE+PC STAGE #
+##################
+
+- oran_cmake_pc_stage: &oran_cmake_pc_stage
+    name: oran-cmake-pc-stage
+
+    ######################
+    # Default parameters #
+    ######################
+
+    branch: master
+    build-days-to-keep: 7
+    build-dir: "$WORKSPACE/target"
+    build-timeout: 15
+    cmake-opts: ""
+    cron: "" # avoid for PackageCloud which rejects duplicates
+    disable-job: false
+    git-url: "$GIT_URL/$PROJECT"
+    github-url: "https://github.com"
+    install-prefix: "$BUILD_DIR/output"
+    make-opts: ""
+    pre-build: ""
+    stream: master
+    submodule-recursive: true
+    submodule-timeout: 10
+    submodule-disable: false
+
+    gerrit_trigger_file_paths:
+      - compare-type: REG_EXP
+        pattern: ".*"
+
+    # github_included_regions MUST match gerrit_trigger_file_paths
+    github_included_regions:
+      - ".*"
+
+    builders:
+      - config-file-provider:
+          files:
+            - file-id: ".packagecloud"
+              target: "$HOME/.packagecloud"
+      - shell: "{pre-build}"
+      - shell: !include-raw-escape: ../../global-jjb/shell/cmake-build.sh
+      - oran-packagecloud-push:
+          packagecloud-account: "{packagecloud-account}"
+          packagecloud-repo: "{packagecloud-repo}"
+          debian-distribution-versions: "{debian-distribution-versions}"
+          rpm-distribution-versions: "{rpm-distribution-versions}"
+
+- job-template:
+    # build with cmake and publish to PackageCloud on command
+    name: "{project-name}-cmake-pc-stage-{stream}"
+    id: oran-gerrit-cmake-pc-stage
+    <<: *oran_cmake_common
+    <<: *oran_cmake_pc_stage
+
+    ######################
+    # Default parameters #
+    ######################
+
+    gerrit_stage_triggers:
+      - comment-added-contains-event:
+          comment-contains-value: '^Patch Set\s+\d+:\s+stage-release\s*$'
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    scm:
+      - lf-infra-gerrit-scm:
+          jenkins-ssh-credential: "{jenkins-ssh-credential}"
+          git-url: "{git-url}"
+          refspec: "$GERRIT_REFSPEC"
+          branch: "$GERRIT_BRANCH"
+          submodule-recursive: "{submodule-recursive}"
+          submodule-timeout: "{submodule-timeout}"
+          submodule-disable: "{submodule-disable}"
+          # stage jobs always build from tip
+          choosing-strategy: default
+
+    triggers:
+      - timed: "{obj:cron}"
+      - gerrit:
+          server-name: "{gerrit-server-name}"
+          trigger-on: "{obj:gerrit_stage_triggers}"
+          projects:
+            - project-compare-type: ANT
+              project-pattern: "{project}"
+              branches:
+                - branch-compare-type: ANT
+                  branch-pattern: "**/{branch}"
+              file-paths: "{obj:gerrit_trigger_file_paths}"
index be44983..601aee1 100644 (file)
 #   limitations under the License.
 
 # Macros and templates for using Docker as the CI system.
+
 # The merge template calls builders to build in docker,
 # export files, then push to PackageCloud.
 # The docker image is discarded, not pushed to a registry.
 # Uses builders defined in, and mirrors the structure of,
 # global-jjb resource jjb/lf-docker-jobs.yaml
 
-- builder:
-    name: oran-packagecloud-file-provider
-    builders:
-      - config-file-provider:
-          files:
-            - file-id: ".packagecloud"
-              target: "$HOME/.packagecloud"
-      - config-file-provider:
-          files:
-            - file-id: "packagecloud_api"
-              target: "$HOME/packagecloud_api"
-
 # This shell script launches the container, which copies
 # build products to a mounted volume.  Script needs vars
 # CONTAINER_PUSH_REGISTRY, DOCKER_NAME and DOCKER_IMAGE_TAG
       - shell: !include-raw-escape:
           - ../shell/export-packages.sh
 
-- builder:
-    # {packagecloud-account} is PackageCloud account ID; example: oran
-    # {packagecloud-repo} is PackageCloud repository; example: master, staging
-    # {debian-distribution-versions} is list of DEB package distro/version strings
-    #    separated by space; example: ubuntu/bionic debian/stretch
-    # {rpm-distribution-versions} is list of RPM package distro/version strings
-    #    separated by space; example: el/4 el/5
-    name: oran-packagecloud-push
-    builders:
-      - inject:
-          properties-content: |
-            PACKAGECLOUD_ACCOUNT={packagecloud-account}
-            PACKAGECLOUD_REPO={packagecloud-repo}
-            DEBIAN_DISTRIBUTION_VERSIONS={debian-distribution-versions}
-            RPM_DISTRIBUTION_VERSIONS={rpm-distribution-versions}
-      - shell: !include-raw-escape:
-          - ../shell/packagecloud-push.sh
-
 # Different name, same content as lf_docker_common
 - oran_docker_common: &oran_docker_common
     name: oran-docker-ci-common
diff --git a/jjb/oran-templates/oran-package-cloud-macros.yaml b/jjb/oran-templates/oran-package-cloud-macros.yaml
new file mode 100644 (file)
index 0000000..2005d57
--- /dev/null
@@ -0,0 +1,46 @@
+---
+#   Copyright (c) 2020 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+# Macros to invoke shell scripts for PackageCloud
+
+- builder:
+    name: oran-packagecloud-file-provider
+    builders:
+      - config-file-provider:
+          files:
+            - file-id: ".packagecloud"
+              target: "$HOME/.packagecloud"
+      - config-file-provider:
+          files:
+            - file-id: "packagecloud_api"
+              target: "$HOME/packagecloud_api"
+
+- builder:
+    # {packagecloud-account} is PackageCloud account ID; example: oran
+    # {packagecloud-repo} is PackageCloud repository; example: master, staging
+    # {debian-distribution-versions} is list of DEB package distro/version strings
+    #    separated by space; example: ubuntu/bionic debian/stretch
+    # {rpm-distribution-versions} is list of RPM package distro/version strings
+    #    separated by space; example: el/4 el/5
+    name: oran-packagecloud-push
+    builders:
+      - inject:
+          properties-content: |
+            PACKAGECLOUD_ACCOUNT={packagecloud-account}
+            PACKAGECLOUD_REPO={packagecloud-repo}
+            DEBIAN_DISTRIBUTION_VERSIONS={debian-distribution-versions}
+            RPM_DISTRIBUTION_VERSIONS={rpm-distribution-versions}
+      - shell: !include-raw-escape:
+          - ../shell/packagecloud-push.sh
index f28f515..5fd387b 100644 (file)
     mvn-settings: ric-plt-xapp-frame-cpp-settings
     # test scripts depend on this name
     build-dir: $WORKSPACE/build
-    # use an ubuntu for its modern compiler and cmake
-    build-node: ubuntu1804-builder-2c-2g
-    # install RMR per version file in repo
+    # Use ubuntu base for cmake v3
+    # Use docker variant for packagecloud ruby gem
+    build-node: ubuntu1804-docker-4c-4g
+    # install RMR per version file in repo for ubuntu
     pre-build: !include-raw-escape:
       - ../shell/install-deb-rmr3.sh
     # verify and sonar use cmake
     cmake-opts: -DDEV_PKG=1
     make-opts: install test ARGS=-V
 
-# verify changes
+# verify on changes, publish on stage
 - project:
     name: xapp-frame-cpp-verify
     <<: *xapp_frame_cpp_common
     jobs:
       - gerrit-cmake-verify
+      - oran-gerrit-cmake-pc-stage
     stream:
       - master:
           branch: master