blob: cc12b36c4f9529d487c50d070db1059bb0ecdcea [file] [log] [blame]
---
# CORD JJB macros
# control how long builds and artifact are retained
- property:
name: cord-infra-properties
properties:
- build-discarder:
days-to-keep: '{build-days-to-keep}'
artifact-num-to-keep: '{artifact-num-to-keep}'
# checkout entire source tree with repo
# docs: https://docs.openstack.org/infra/jenkins-job-builder/scm.html#scm.repo
- scm:
name: cord-infra-gerrit-repo-scm
scm:
- repo:
manifest-url: '{manifest-url}'
manifest-branch: '{branch}'
destination-dir: '{destination-dir}'
jobs: 4
reset-first: true
depth: 1
# same as lf-infra-gerrit-scm, but allows checkouts to a subdir of $WORKSPACE
# with the `basedir` option
#
# `basedir` serves the same function as `destination-dir` in the repo scm
# macros, seems strange that they're named differently.
- scm:
name: cord-infra-gerrit-scm
scm:
- git:
credentials-id: '{jenkins-ssh-credential}'
url: '{git-url}'
refspec: '{refspec}'
branches:
- 'refs/heads/{branch}'
skip-tag: true
wipe-workspace: true
submodule:
recursive: '{submodule-recursive}'
choosing-strategy: '{choosing-strategy}'
basedir: '{basedir}'
# download a specific patchset after checking out entire source tree with repo
# docs: https://docs.openstack.org/infra/jenkins-job-builder/builders.html#builders.inject
- builder:
name: cord-infra-gerrit-repo-patch
builders:
- inject:
properties-content: |
DESTINATION_DIR={destination-dir}
GERRIT_PROJECT={project}
GERRIT_CHANGE_NUMBER={change-number}
GERRIT_PATCHSET_NUMBER={patchset-number}
- shell: !include-raw-escape: shell/repopatch.sh
# sonarqube-ongoing-coverage
- builder:
name: cord-infra-sonarqube
builders:
- inject:
properties-content: |
SONAR_PREP_COMMANDS={sonar-prep-commands}
- shell: !include-raw-escape: shell/sonarprep.sh
- sonar:
sonar-name: 'sonar.opencord.org'
java-opts: '-Xmx1280m'
properties: |
sonar.sources=.
sonar.projectKey={project}_$GERRIT_BRANCH
sonar.python.pylint=/usr/local/bin/pylint
sonar.java.binaries={sonar-java-binaries}
# trigger on gerrit patchsets and actions
# docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit
- trigger:
name: cord-infra-gerrit-trigger-patchset
triggers:
- gerrit:
server-name: '{gerrit-server-name}'
dependency-jobs: '{dependency-jobs}'
silent-start: true
trigger-on:
- patchset-created-event:
exclude-drafts: true
exclude-trivial-rebase: false
exclude-no-code-change: true
- draft-published-event
- comment-added-contains-event:
comment-contains-value: '(?i)^.*recheck$'
projects:
- project-compare-type: REG_EXP
project-pattern: '{project-regexp}'
branches:
- branch-compare-type: REG_EXP
branch-pattern: '{branch-regexp}'
file-paths:
- compare-type: REG_EXP
pattern: '{file-include-regexp}'
# trigger on gerrit commits/merges
- trigger:
name: cord-infra-gerrit-trigger-merge
triggers:
- gerrit:
server-name: '{gerrit-server-name}'
dependency-jobs: '{dependency-jobs}'
silent-start: true
trigger-on:
- change-merged-event
projects:
- project-compare-type: REG_EXP
project-pattern: '{project-regexp}'
branches:
- branch-compare-type: REG_EXP
branch-pattern: '{branch-regexp}'
file-paths:
- compare-type: REG_EXP
pattern: '{file-include-regexp}'
# Trigger on GitHub pull requests
# docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.github-pull-request
# Uses the standard 'ok to test', etc. commands per the plugin:
# https://github.com/jenkinsci/ghprb-plugin
- trigger:
name: cord-infra-github-pr-trigger
triggers:
- github-pull-request:
auth-id: '{github_pr_auth_id}'
github-hooks: true # Create github hooks automatically
cancel-builds-on-update: true
auto-close-on-fail: false
only-trigger-phrase: false
status-context: '{status_context}' # Name of testing system in PR
permit-all: false # don't trigger on every PR
org-list: '{obj:github_pr_org_list}'
allow-whitelist-orgs-as-admins: true
# Trigger on GitHub PR merge
# docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.generic-webhook-trigger
- trigger:
name: cord-infra-github-pr-trigger-merge
triggers:
- generic-webhook-trigger:
post-content-params:
- type: JSONPath
key: action
value: $.action
- type: JSONPath
key: merged
value: $.pull_request.merged
- type: JSONPath
key: branchName
value: $.pull_request.base.ref
- type: JSONPath
key: gitRef
value: $.pull_request.base.ref
regex-filter-text: $action,$merged
regex-filter-expression: ^(closed,true)$
cause: Generic Cause
token: '{project}'
# wrapper to provide pypi config file
- wrapper:
name: cord-pypi-wrapper
wrappers:
- mask-passwords
- timeout:
type: absolute
timeout: '{build-timeout}'
timeout-var: 'BUILD_TIMEOUT'
fail: true
- timestamps
- ssh-agent-credentials:
users:
- '{jenkins-ssh-credential}'
- config-file-provider:
files:
- file-id: pypirc
target: '$HOME/.pypirc'
- file-id: pipconf
target: '$HOME/.config/pip/pip.conf'
# wrapper to provide SSH key and fill in ~/.ssh/known_hosts file for use with rsync
# Name matches macro in ONOS JJB, for future unification
- wrapper:
name: onf-infra-rsync-wrappers
wrappers:
- mask-passwords
- timeout:
type: absolute
timeout: '{build-timeout}'
timeout-var: 'BUILD_TIMEOUT'
fail: true
- timestamps
- ssh-agent-credentials:
users:
- '{jenkins-ssh-credential}'
- config-file-provider:
files:
- file-id: known_hosts
target: '$HOME/.ssh/known_hosts'