Skip to content

Commit

Permalink
ci: workflow on PR, merges and nightlies (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Feb 9, 2022
1 parent ba21150 commit 5ccf1b1
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 1 deletion.
45 changes: 44 additions & 1 deletion .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ pipeline {
quietPeriod(10)
}
triggers {
issueCommentTrigger("${obltGitHubComments()}")
issueCommentTrigger("(${obltGitHubComments()}|^run ((integration|end-to-end) tests|package)")
}
parameters {
// disabled by default, but required for merge, there are two GH checks:
// opt-in with 'ci:integration'
booleanParam(name: 'integration_tests_ci', defaultValue: false, description: 'Enable Integration tests')

// disabled by default, but required for merge:
// opt-in with 'ci:end-to-end' tag on PR
booleanParam(name: 'end_to_end_tests_ci', defaultValue: false, description: 'Enable End-to-End tests')
}
stages {
stage('Checkout') {
Expand Down Expand Up @@ -94,6 +103,14 @@ pipeline {
}
}
stage('Package') {
when {
beforeAgent true
anyOf {
expression { return env.GITHUB_COMMENT?.contains('package') }
expression { matchesPrLabel(label: 'ci:package') }
not { changeRequest() }
}
}
failFast false
matrix {
agent {label "${PLATFORM}"}
Expand Down Expand Up @@ -124,6 +141,32 @@ pipeline {
}
}
}
stage('e2e tests') {
when {
beforeAgent true
anyOf {
expression { return params.end_to_end_tests_ci }
expression { return env.GITHUB_COMMENT?.contains('e2e tests') }
expression { matchesPrLabel(label: 'ci:end-to-end') }
}
}
steps {
echo 'TBD'
}
}
stage('Integration tests') {
when {
beforeAgent true
anyOf {
expression { return params.integration_tests_ci }
expression { return env.GITHUB_COMMENT?.contains('integration tests') }
expression { matchesPrLabel(label: 'ci:integration') }
}
}
steps {
echo 'TBD'
}
}
}
post {
cleanup {
Expand Down
26 changes: 26 additions & 0 deletions .ci/jobs/elastic-agent-schedule-daily.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- job:
name: "elastic-agent/elastic-agent-schedule-daily"
display-name: Jobs scheduled daily (weekdays)
description: Jobs scheduled daily (weekdays)
view: Beats
project-type: pipeline
parameters:
- string:
name: branch_specifier
default: main
description: the Git branch specifier to build
pipeline-scm:
script-path: .ci/schedule-daily.groovy
scm:
- git:
url: git@github.com:elastic/elastic-agent-poc.git
refspec: +refs/heads/*:refs/remotes/origin/*
wipe-workspace: 'True'
name: origin
shallow-clone: true
credentials-id: f6c7695a-671e-4f4f-a331-acdce44ff9ba
branches:
- $branch_specifier
triggers:
- timed: 'H H(2-3) * * 1-5'
73 changes: 73 additions & 0 deletions .ci/schedule-daily.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
@Library('apm@current') _

pipeline {
agent none
environment {
NOTIFY_TO = credentials('notify-to')
PIPELINE_LOG_LEVEL = 'INFO'
}
options {
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20'))
timestamps()
ansiColor('xterm')
disableResume()
durabilityHint('PERFORMANCE_OPTIMIZED')
}
triggers {
cron('H H(2-3) * * 1-5')
}
stages {
stage('Nighly beats builds') {
steps {
runBuilds(quietPeriodFactor: 2000, branches: ['main', '8.<minor>', '7.<minor>', '7.<next-minor>'])
}
}
}
post {
cleanup {
notifyBuildResult(prComment: false)
}
}
}

def runBuilds(Map args = [:]) {
def branches = []
// Expand macros and filter duplicated matches.
args.branches.each { branch ->
def branchName = getBranchName(branch)
if (!branches.contains(branchName)) {
branches << branchName
}
}

def quietPeriod = 0
branches.each { branch ->
build(quietPeriod: quietPeriod,
job: "elastic-agent/elastic-agent-poc-mbp/${branch}",
parameters: [
booleanParam(name: 'integration_tests_ci', value: true),
booleanParam(name: 'end_to_end_tests_ci', value: true)
],
wait: false, propagate: false)
// Increate the quiet period for the next iteration
quietPeriod += args.quietPeriodFactor
}
}

def getBranchName(branch) {
// special macro to look for the latest minor version
if (branch.contains('8.<minor>')) {
return bumpUtils.getMajorMinor(bumpUtils.getCurrentMinorReleaseFor8())
}
if (branch.contains('8.<next-minor>')) {
return bumpUtils.getMajorMinor(bumpUtils.getNextMinorReleaseFor8())
}
if (branch.contains('7.<minor>')) {
return bumpUtils.getMajorMinor(bumpUtils.getCurrentMinorReleaseFor7())
}
if (branch.contains('7.<next-minor>')) {
return bumpUtils.getMajorMinor(bumpUtils.getNextMinorReleaseFor7())
}
return branch
}

0 comments on commit 5ccf1b1

Please sign in to comment.