Skip to content

Commit

Permalink
[JJBB][CI] Run beats-tester on master and release branches (#21169) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Sep 21, 2020
1 parent 6c97222 commit 5014964
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 0 deletions.
106 changes: 106 additions & 0 deletions .ci/beats-tester.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/usr/bin/env groovy

@Library('apm@current') _

pipeline {
agent none
environment {
BASE_DIR = 'src/github.com/elastic/beats'
PIPELINE_LOG_LEVEL = "INFO"
BEATS_TESTER_JOB = 'Beats/beats-tester-mbp/master'
}
options {
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30'))
timestamps()
ansiColor('xterm')
disableResume()
durabilityHint('PERFORMANCE_OPTIMIZED')
disableConcurrentBuilds()
}
triggers {
issueCommentTrigger('(?i)^\\/beats-tester$')
upstream("Beats/packaging/${env.JOB_BASE_NAME}")
}
stages {
stage('Filter build') {
agent { label 'ubuntu && immutable' }
when {
beforeAgent true
anyOf {
triggeredBy cause: "IssueCommentCause"
expression {
def ret = isUserTrigger() || isUpstreamTrigger()
if(!ret){
currentBuild.result = 'NOT_BUILT'
currentBuild.description = "The build has been skipped"
currentBuild.displayName = "#${BUILD_NUMBER}-(Skipped)"
echo("the build has been skipped due the trigger is a branch scan and the allow ones are manual, GitHub comment, and upstream job")
}
return ret
}
}
}
stages {
stage('Checkout') {
options { skipDefaultCheckout() }
steps {
deleteDir()
gitCheckout(basedir: "${BASE_DIR}")
setEnvVar('VERSION', sh(script: "grep ':stack-version:' ${BASE_DIR}/libbeat/docs/version.asciidoc | cut -d' ' -f2", returnStdout: true).trim())
}
}
stage('Build master') {
options { skipDefaultCheckout() }
when { branch 'master' }
steps {
runBeatsTesterJob(version: "${env.VERSION}-SNAPSHOT")
}
}
stage('Build *.x branch') {
options { skipDefaultCheckout() }
when { branch '*.x' }
steps {
runBeatsTesterJob(version: "${env.VERSION}-SNAPSHOT")
}
}
stage('Build PullRequest') {
options { skipDefaultCheckout() }
when { changeRequest() }
steps {
runBeatsTesterJob(version: "${env.VERSION}-SNAPSHOT",
apm: "https://storage.googleapis.com/apm-ci-artifacts/jobs/pull-requests/pr-${env.CHANGE_ID}",
beats: "https://storage.googleapis.com/beats-ci-artifacts/pull-requests/pr-${env.CHANGE_ID}")
}
}
stage('Build release branch') {
options { skipDefaultCheckout() }
when {
not {
allOf {
branch comparator: 'REGEXP', pattern: '(master|.*x)'
changeRequest()
}
}
}
steps {
runBeatsTesterJob(version: "${env.VERSION}-SNAPSHOT")
}
}
}
}
}
}

def runBeatsTesterJob(Map args = [:]) {
if (args.apm && args.beats) {
build(job: env.BEATS_TESTER_JOB, propagate: false, wait: false,
parameters: [
string(name: 'APM_URL_BASE', value: args.apm),
string(name: 'BEATS_URL_BASE', value: args.beats),
string(name: 'VERSION', value: args.version)
])
} else {
build(job: env.BEATS_TESTER_JOB, propagate: false, wait: false, parameters: [ string(name: 'VERSION', value: args.version) ])
}
}
56 changes: 56 additions & 0 deletions .ci/jobs/beats-tester.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
- job:
name: Beats/beats-tester
display-name: Beats Tester
description: Run the beats-tester
view: Beats
disabled: false
project-type: multibranch
script-path: .ci/beats-tester.groovy
scm:
- github:
branch-discovery: 'no-pr'
discover-pr-forks-strategy: 'merge-current'
discover-pr-forks-trust: 'permission'
discover-pr-origin: 'merge-current'
discover-tags: true
head-filter-regex: '(master|7\.([x9]|1\d+)|8\.\d+|PR-.*|v\d+\.\d+\.\d+)'
disable-pr-notifications: true
notification-context: 'beats-tester'
repo: 'beats'
repo-owner: 'elastic'
credentials-id: github-app-beats-ci
ssh-checkout:
credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
build-strategies:
- skip-initial-build: true
- tags:
ignore-tags-older-than: -1
ignore-tags-newer-than: 30
- named-branches:
- exact-name:
name: 'master'
case-sensitive: true
- regex-name:
regex: '7\.([x9]|1\d+)'
case-sensitive: true
- regex-name:
regex: '8\.\d+'
case-sensitive: true
- change-request:
ignore-target-only-changes: true
clean:
after: true
before: true
prune: true
shallow-clone: true
depth: 3
do-not-fetch-tags: true
submodule:
disable: false
recursive: true
parent-credentials: true
timeout: 100
timeout: '15'
use-author: true
wipe-workspace: true
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ It is possible to trigger some jobs by putting a comment on a GitHub PR.
* `/test macos` will kick off a default build with also the `macos` stages.
* [apm-beats-update][]
* `/run apm-beats-update`
* [apm-beats-packaging][]
* `/package` or `/packaging` will kick of a build to generate the packages for beats.
* [apm-beats-tester][]
* `/beats-tester` will kick of a build to validate the generated packages.


[beats]: https://beats-ci.elastic.co/job/Beats/job/beats-beats-mbp/
[apm-beats-update]: https://beats-ci.elastic.co/job/Beats/job/apm-beats-update/
[apm-beats-packaging]: https://beats-ci.elastic.co/job/Beats/job/packaging/
[apm-beats-tester]: https://beats-ci.elastic.co/job/Beats/job/beats-tester/

0 comments on commit 5014964

Please sign in to comment.