From: Srinivasan Selvam Date: Tue, 5 May 2020 14:17:34 +0000 (+0530) Subject: Added jjb-files for CI X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=56066983f04d6186fe5d114cbd767397210dbb48;p=ealt-edge.git Added jjb-files for CI Signed-off-by: Srinivasan Selvam Change-Id: I2a0f538241acf2630611dd64f9461a9f3522037f --- diff --git a/ci/daily build/base-macros.yaml b/ci/daily build/base-macros.yaml new file mode 100644 index 0000000..92d315c --- /dev/null +++ b/ci/daily build/base-macros.yaml @@ -0,0 +1,285 @@ +--- +# Base macros +# +# NOTE: make sure macros are listed in execution ordered. +# +# 1. parameters/properties +# 2. scm +# 3. triggers +# 4. wrappers +# 5. prebuilders (maven only, configured like Builders) +# 6. builders (maven, freestyle, matrix, etc..) +# 7. postbuilders (maven only, configured like Builders) +# 8. publishers/reporters/notifications + +- parameter: + name: project-parameter + parameters: + - string: + name: PROJECT + default: '{project}' + description: "JJB configured PROJECT parameter" + - string: + name: GS_BASE + default: artifacts.akraino.org/$PROJECT + description: "URL to Google Storage." + - string: + name: BRANCH + default: '{branch}' + description: "JJB configured BRANCH parameter" + - string: + name: GERRIT_BRANCH + default: '{branch}' + description: "JJB configured GERRIT_BRANCH parameter (deprecated)" + - string: + name: GERRIT_REFSPEC + default: 'refs/heads/{branch}' + description: "Default refspec needed for manually triggering." + + +- property: + name: logrotate-default + properties: + - build-discarder: + days-to-keep: 60 + num-to-keep: 200 + artifact-days-to-keep: 60 + artifact-num-to-keep: 200 + +- scm: + name: git-scm + scm: + - git: &git-scm-defaults + credentials-id: 'jenkins-ssh' + url: '$GIT_BASE' + branches: + - 'origin/$BRANCH' + timeout: 15 + per-build-tag: false + skip-tag: true + shallow-clone: false + use-author: false + ignore-notify: false + wipe-workspace: true + prune: false + +- scm: + name: git-scm-gerrit + scm: + - git: + choosing-strategy: 'gerrit' + refspec: '$GERRIT_REFSPEC' + <<: *git-scm-defaults + +- scm: + name: git-scm-gerrit-with-submodules + scm: + - git: + choosing-strategy: 'gerrit' + refspec: '$GERRIT_REFSPEC' + submodule: + recursive: true + timeout: 20 + <<: *git-scm-defaults + +- trigger: + name: 'daily-trigger-disabled' + triggers: + - timed: '' + +- trigger: + name: 'weekly-trigger-disabled' + triggers: + - timed: '' + +- trigger: + name: gerrit-trigger-patchset-created + triggers: + - gerrit: + server-name: 'gerrit.akraino.org' + trigger-on: + - patchset-created-event: + exclude-drafts: 'false' + exclude-trivial-rebase: 'false' + exclude-no-code-change: 'false' + - draft-published-event + - comment-added-contains-event: + comment-contains-value: 'recheck' + - comment-added-contains-event: + comment-contains-value: 'reverify' + projects: + - project-compare-type: 'ANT' + project-pattern: '{project}' + branches: + - branch-compare-type: 'ANT' + branch-pattern: '**/{branch}' + file-paths: + - compare-type: 'ANT' + pattern: '{files}' + skip-vote: + successful: false + failed: false + unstable: false + notbuilt: false + +- wrapper: + name: ssh-agent-wrapper + wrappers: + - ssh-agent-credentials: + users: + - 'jenkins-ssh' + +- wrapper: + name: build-timeout + wrappers: + - timeout: + timeout: '{timeout}' + timeout-var: 'BUILD_TIMEOUT' + fail: true + +- wrapper: + name: fix-workspace-permissions + wrappers: + - pre-scm-buildstep: + - shell: | + #!/bin/bash + sudo chown -R $USER:$USER $WORKSPACE || exit 1 + +- builder: + name: upload-under-review-docs-to-akraino-artifacts + builders: + - shell: | + #!/bin/bash + set -o errexit + set -o pipefail + set -o xtrace + export PATH=$PATH:/usr/local/bin/ + + [[ $GERRIT_CHANGE_NUMBER =~ .+ ]] + [[ -d docs/_build/ ]] || exit 0 + + echo + echo "###########################" + echo "UPLOADING DOCS UNDER REVIEW" + echo "###########################" + echo + + gs_base="artifacts.akraino.org/$PROJECT/review" + gs_path="$gs_base/$GERRIT_CHANGE_NUMBER" + local_path="upload/$GERRIT_CHANGE_NUMBER" + + mkdir -p upload + mv docs/_build/html/ "$local_path" + gsutil -m cp -r "$local_path" "gs://$gs_base" + + gsutil -m setmeta \ + -h "Content-Type:text/html" \ + -h "Cache-Control:private, max-age=0, no-transform" \ + "gs://$gs_path"/**.html > /dev/null 2>&1 + + echo "Document link(s):" >> gerrit_comment.txt + find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \ + sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt + +# To take advantage of this macro, have your build write +# out the file 'gerrit_comment.txt' with information to post +# back to gerrit and include this macro in the list of builders. +- builder: + name: report-build-result-to-gerrit + builders: + - shell: | + #!/bin/bash + set -o errexit + set -o pipefail + set -o xtrace + export PATH=$PATH:/usr/local/bin/ + if [[ -e gerrit_comment.txt ]] ; then + echo + echo "posting review comment to gerrit..." + echo + cat gerrit_comment.txt + echo + ssh -p 29418 gerrit.akraino.org \ + "gerrit review -p $GERRIT_PROJECT \ + -m '$(cat gerrit_comment.txt)' \ + $GERRIT_PATCHSET_REVISION \ + --notify NONE" + fi + +- builder: + name: remove-old-docs-from-akraino-artifacts + builders: + - shell: | + #!/bin/bash + set -o errexit + set -o pipefail + set -o xtrace + export PATH=$PATH:/usr/local/bin/ + + [[ $GERRIT_CHANGE_NUMBER =~ .+ ]] + + gs_path="artifacts.akraino.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER" + + if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then + echo + echo "Deleting Out-of-dated Documents..." + gsutil -m rm -r "gs://$gs_path" + fi + gs_path="artifacts.akraino.org/review/$GERRIT_CHANGE_NUMBER" + + if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then + echo + echo "Deleting Out-of-dated Documents..." + gsutil -m rm -r "gs://$gs_path" + fi + +- builder: + name: upload-review-docs + builders: + - upload-under-review-docs-to-akraino-artifacts + - report-build-result-to-gerrit + + +- builder: + name: clean-workspace + builders: + - shell: | + #!/bin/bash + set -o errexit + set -o nounset + set -o pipefail + sudo /bin/rm -rf "$WORKSPACE" + +- builder: + name: clean-workspace-log + builders: + - shell: | + find $WORKSPACE -type f -name '*.log' | xargs rm -f + +- publisher: + name: archive-artifacts + publishers: + - archive: + artifacts: '{artifacts}' + allow-empty: true + fingerprint: true + latest-only: true + +- publisher: + name: publish-coverage + publishers: + - cobertura: + report-file: "coverage.xml" + only-stable: "true" + health-auto-update: "false" + stability-auto-update: "false" + zoom-coverage-chart: "true" + targets: + - files: + healthy: 10 + unhealthy: 20 + failing: 30 + - method: + healthy: 50 + unhealthy: 40 + failing: 30 diff --git a/ci/daily build/defaults.yaml b/ci/daily build/defaults.yaml new file mode 100644 index 0000000..3e9f8e9 --- /dev/null +++ b/ci/daily build/defaults.yaml @@ -0,0 +1,10 @@ +--- +# jjb defaults +- defaults: + name: global + + gerrit-server-name: Primary + git-url: 'ssh://akraino-jobbuilder@gerrit.akraino.org:29418' + jenkins-ssh-credential: jenkins-ssh + lftools-version: '<1.0.0' + submodule-timeout: 10 diff --git a/ci/daily build/ealt-edge-ci-jobs .yaml b/ci/daily build/ealt-edge-ci-jobs .yaml new file mode 100644 index 0000000..95d8d08 --- /dev/null +++ b/ci/daily build/ealt-edge-ci-jobs .yaml @@ -0,0 +1,127 @@ +--- +- project: + + name: ealt-edge-ci + + installer: 'ealt-edge' + + project: 'ealt-edge' + + master: &master + stream: master + branch: '{stream}' + gs-pathname: '' + ppa-pathname: '/{stream}' + disabled: false + # ------------------------------- + # POD, INSTALLER, AND BRANCH MAPPING + # ------------------------------- + # CI PODs + # ------------------------------- + pod: + - k8s-virtual: + slave-label: mec-k8s-virtual + <<: *master + auto-trigger-name: 'ealt-edge-deploy-{pod}-daily-{stream}' + + + jobs: + - 'ealt-edge-deploy-{pod}-daily-{stream}' + +######################## +# job templates +######################## +- job-template: + name: 'ealt-edge-deploy-{pod}-daily-{stream}' + + disabled: '{obj:disabled}' + + concurrent: true + + properties: + - logrotate-default + - throttle: + enabled: true + max-per-node: 1 + option: 'project' + - build-blocker: + use-build-blocker: true + blocking-jobs: + - 'ealt-edge-deploy-{pod}-daily-.*?' + - 'ealt-edge-verify-deploy-.*?' + blocking-level: 'NODE' + + + wrappers: + - build-name: + name: '$BUILD_NUMBER' + - timeout: + timeout: 360 + abort: true + - fix-workspace-permissions + + parameters: + - project-parameter: + project: '{project}' + branch: '{branch}' + - ealt-edge-ci-parameter: + installer: '{installer}' + gs-pathname: '{gs-pathname}' + ppa-pathname: '{ppa-pathname}' + - '{slave-label}-defaults' + - '{installer}-defaults' + + triggers: + - '{auto-trigger-name}' + + scm: + - git-scm + + builders: + - description-setter: + description: "POD: $NODE_NAME" + - conditional-step: + condition-kind: regex-match + regex: "k8s-.*" + label: '{pod}' + steps: + - shell: + !include-raw-escape: ./ealt-edge-clean.sh + - shell: + !include-raw-escape: ./ealt-edge-deploy.sh + +######################## +# parameter macros +######################## +- parameter: + name: ealt-edge-ci-parameter + parameters: + - string: + name: GS_URL + default: '$GS_BASE{gs-pathname}' + description: "URL to Google Storage." + - string: + name: PPA_REPO + default: "" + - string: + name: PPA_CACHE + default: "$WORKSPACE/work/repo/" + - string: + name: LOG_DIRECTORY + default: $WORKSPACE/log_output + description: "" + + +######################## +# trigger macros +######################## + + +# ----------------- +# virtual-master +# ----------------- + +- trigger: + name: 'ealt-edge-deploy-k8s-virtual-daily-master' + triggers: + - timed: '0 21 * * *' diff --git a/ci/daily build/project-params.yaml b/ci/daily build/project-params.yaml new file mode 100644 index 0000000..88f0176 --- /dev/null +++ b/ci/daily build/project-params.yaml @@ -0,0 +1,16 @@ +--- +- parameter: + name: 'ealt-edge-defaults' + parameters: + - string: + name: NODE_IP + default: "" + description: 'IP of the node' + - string: + name: USERNAME + default: "" + description: 'username of the node' + - string: + name: PASSWORD + default: "" + description: 'password of the node' diff --git a/ci/daily build/slave-params.yaml b/ci/daily build/slave-params.yaml new file mode 100644 index 0000000..b8db620 --- /dev/null +++ b/ci/daily build/slave-params.yaml @@ -0,0 +1,13 @@ +--- +- parameter: + name: 'mec-k8s-virtual-defaults' + parameters: + - label: + name: SLAVE_LABEL + default: 'mec-k8s-virtual' + all-nodes: false + node-eligibility: 'ignore-offline' + - string: + name: GIT_BASE + default: https://gerrit.akraino.org/r/$PROJECT + description: 'Git URL to use on this Jenkins Slave'