Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feature/2.0-beats
Browse files Browse the repository at this point in the history
* upstream/master: (21 commits)
  fix: remove params from JJB definition (#701)
  chore: convert regular pipeline for APM to mbp (#699)
  docs: update CHANGELOG.md
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release v1.1.134
  [CI] git commit with correct user.email (#700)
  docs: update CHANGELOG.md
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release v1.1.133
  fix read only env variable (#698)
  chore: include schedule in JJBB for APM specs sync (#696)
  docs: update CHANGELOG.md
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release v1.1.132
  Fix opbeans-frontend release process (#697)
  Use real email account (#695)
  chore: add force parameter to the JJBB job for APM specs sync (#693)
  docs: update CHANGELOG.md
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release v1.1.131
  ...
  • Loading branch information
v1v committed Sep 3, 2020
2 parents e9e7c1c + eb158ec commit 5ef3587
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pipeline {
NOTIFY_TO = credentials('notify-to')
PIPELINE_LOG_LEVEL = 'DEBUG'
MAVEN_CONFIG = "${params.MAVEN_CONFIG}"
LANG = "C.UTF-8"
LC_ALL = "C.UTF-8"
}
options {
timeout(time: 1, unit: 'HOURS')
Expand Down
24 changes: 0 additions & 24 deletions .ci/jobs/apm-update-gherkin-pipeline.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .ci/jobs/apm-update-specs-mbp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
- job:
name: apm-shared/apm-update-specs-mbp
display-name: APM Update Specs
description: Send PRs to the subscribed APM Agents if the spec files (Gherkin and JSON) are modified, triggered for the master branch for the elastic/apm project
view: APM-CI
project-type: multibranch
script-path: .ci/Jenkinsfile
scm:
- github:
branch-discovery: no-pr
discover-pr-forks-strategy: merge-current
discover-pr-forks-trust: permission
discover-pr-origin: merge-current
discover-tags: false
notification-context: 'apm-ci'
repo: apm
repo-owner: elastic
credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
ssh-checkout:
credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
build-strategies:
- regular-branches: true
- change-request:
ignore-target-only-changes: true
clean:
after: true
before: true
prune: true
shallow-clone: true
depth: 4
do-not-fetch-tags: true
submodule:
disable: false
recursive: true
parent-credentials: true
timeout: 100
timeout: '15'
use-author: true
wipe-workspace: 'True'
triggers:
- timed: 'H H(4-5) * * 1,5'
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## v1.1.134 (18/08/2020)

#### ⚙️ CI

- [CI] git commit with correct user.email [#700](https://github.com/elastic/apm-pipeline-library/pull/700)

## v1.1.133 (18/08/2020)

#### 🐛 Bug Fixes

- fix read only env variable [#698](https://github.com/elastic/apm-pipeline-library/pull/698)

## v1.1.132 (17/08/2020)

#### 🐛 Bug Fixes

- Fix opbeans-frontend release process [#697](https://github.com/elastic/apm-pipeline-library/pull/697)
- Use real email account [#695](https://github.com/elastic/apm-pipeline-library/pull/695)

## v1.1.131 (12/08/2020)

#### 🐛 Bug Fixes

- Control when to send email notifications [#692](https://github.com/elastic/apm-pipeline-library/pull/692)

#### ⚙️ CI

- feat: support passing custom build commands from the target project [#683](https://github.com/elastic/apm-pipeline-library/pull/683)
- fix: typo caused by keyboard strokes [#688](https://github.com/elastic/apm-pipeline-library/pull/688)
- [jjbb] beats mbp is not required in the apm-ci anymore [#690](https://github.com/elastic/apm-pipeline-library/pull/690)
- fix: add the mandatory tag argument [#686](https://github.com/elastic/apm-pipeline-library/pull/686)

## v1.1.130 (21/07/2020)

#### 🐛 Bug Fixes
Expand Down
5 changes: 3 additions & 2 deletions local/test-jjbb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -eo pipefail

## Further details: https://github.com/elastic/infra/blob/master/flavortown/jjbb/README.md#how-do-i-test-changes-locally

JJB_IMAGE="osmman/jenkins-job-builder:3.1.0"
TMPFOLDER=$(mktemp -q -d /tmp/pre-commit.XXXXXX)
LOG_LEVEL="error"

Expand Down Expand Up @@ -53,7 +54,7 @@ docker run -t --rm --user "$(id -u):$(id -g)" \
-v "${TMPFOLDER}:/jjbb" \
-w '/jjbb' \
-e HOME=/tmp \
osmman/jenkins-job-builder:3.1.0 -l "${LOG_LEVEL}" test "${BASENAME}" > "${JJB_REPORT}"
${JJB_IMAGE} -l "${LOG_LEVEL}" test "${BASENAME}" > "${JJB_REPORT}"

# shellcheck disable=SC2181
if [ $? -gt 0 ] ; then
Expand All @@ -71,5 +72,5 @@ docker run -t --rm --user "$(id -u):$(id -g)" \
-w '/jjbb' \
-v "$(pwd)/local/jenkins_jobs.ini":/etc/jenkins_jobs/jenkins_jobs.ini \
--network local_apm-pipeline-library \
osmman/jenkins-job-builder:3.0.2 -l "${LOG_LEVEL}" update "${BASENAME}"
${JJB_IMAGE} -l "${LOG_LEVEL}" update "${BASENAME}"
printf '\tpassed\n'
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>co.elastic</groupId>
<artifactId>jenkins-library</artifactId>
<version>1.1.131-SNAPSHOT</version>
<version>1.1.135-SNAPSHOT</version>
<name>APM Pipeline Shared Library</name>
<description>Pipeline Shared Library containing utility steps.</description>
<url>https://github.com/elastic/apm-pipeline-library</url>
Expand Down
35 changes: 30 additions & 5 deletions src/test/groovy/NotifyBuildResultStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ class NotifyBuildResultStepTests extends ApmBasePipelineTest {
@Test
void testCustomisedEmailWithEmptyOrNull() throws Exception {
def script = loadScript(scriptName)
assertTrue(script.customisedEmail('').equals(''))
assertTrue(script.customisedEmail(null).equals(''))
assertTrue(script.customisedEmail('').equals([]))
assertTrue(script.customisedEmail(null).equals([]))
assertJobStatusSuccess()
}

Expand All @@ -169,7 +169,7 @@ class NotifyBuildResultStepTests extends ApmBasePipelineTest {
env.REPO = 'foo'
env.remove('JOB_NAME')
def result = script.customisedEmail('build-apm@example.com')
assertTrue(result.equals('build-apm+foo@example.com'))
assertTrue(result.equals(['build-apm+foo@example.com']))
assertJobStatusSuccess()
}

Expand All @@ -178,7 +178,7 @@ class NotifyBuildResultStepTests extends ApmBasePipelineTest {
def script = loadScript(scriptName)
env.REPO = 'foo'
env.JOB_NAME = 'folder1/folder2/foo'
assertTrue(script.customisedEmail('build-apm@example.com').equals('build-apm+folder1@example.com'))
assertTrue(script.customisedEmail('build-apm@example.com').equals(['build-apm+folder1@example.com']))
assertJobStatusSuccess()
}

Expand All @@ -187,10 +187,35 @@ class NotifyBuildResultStepTests extends ApmBasePipelineTest {
def script = loadScript(scriptName)
env.REPO = ''
env.JOB_NAME = ''
assertTrue(script.customisedEmail('build-apm@example.com').equals('build-apm@example.com'))
assertTrue(script.customisedEmail('build-apm@example.com').equals(['build-apm@example.com']))
assertJobStatusSuccess()
}

@Test
void test_email_without_NOTIFY_TO() throws Exception {
def script = loadScript(scriptName)
env.remove('NOTIFY_TO')
script.call(shouldNotify: true)
printCallStack()
assertFalse(assertMethodCallContainsPattern('log', 'notifyBuildResult: Notifying results by email.'))
}

@Test
void test_email_with_NOTIFY_TO() throws Exception {
def script = loadScript(scriptName)
script.call(shouldNotify: true)
printCallStack()
assertTrue(assertMethodCallContainsPattern('log', 'notifyBuildResult: Notifying results by email.'))
}

@Test
void test_email_with_to() throws Exception {
def script = loadScript(scriptName)
script.call(shouldNotify: true, to: ['foo@acme.com'])
printCallStack()
assertTrue(assertMethodCallContainsPattern('log', 'notifyBuildResult: Notifying results by email.'))
}

@Test
void testRebuildWhenEnvIssueAlreadySet() throws Exception {
def script = loadScript(scriptName)
Expand Down
12 changes: 12 additions & 0 deletions src/test/groovy/OpbeansPipelineStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ class OpbeansPipelineStepTests extends ApmBasePipelineTest {
assertJobStatusSuccess()
}

@Test
void test_when_tag_release_for_opbeans_frontend() throws Exception {
def script = loadScript(scriptName)
// When the tag release does match
env.BRANCH_NAME = '@elastic/apm-rum@1.0'
script.call()
printCallStack()
// Then publish shell step
assertTrue(assertMethodCallContainsPattern('sh', 'VERSION=agent-1.0 make publish'))
assertJobStatusSuccess()
}

@Test
void test_getForkedRepoOrElasticRepo() throws Exception {
def script = loadScript(scriptName)
Expand Down
10 changes: 5 additions & 5 deletions vars/notifyBuildResult.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def call(Map args = [:]) {
stage('Reporting build status'){
def secret = args.containsKey('secret') ? args.secret : 'secret/observability-team/ci/jenkins-stats-cloud'
def es = args.containsKey('es') ? args.es : getVaultSecret(secret: secret)?.data.url
def to = args.containsKey('to') ? args.to : [ customisedEmail(env.NOTIFY_TO)]
def to = args.containsKey('to') ? args.to : customisedEmail(env.NOTIFY_TO)
def statsURL = args.containsKey('statsURL') ? args.statsURL : "https://ela.st/observabtl-ci-stats"
def shouldNotify = args.containsKey('shouldNotify') ? args.shouldNotify : !isPR() && currentBuild.currentResult != "SUCCESS"

Expand All @@ -54,7 +54,7 @@ def call(Map args = [:]) {
data['emailRecipients'] = to
data['statsUrl'] = statsURL
def notificationManager = new NotificationManager()
if(shouldNotify){
if(shouldNotify && !to?.empty){
log(level: 'DEBUG', text: 'notifyBuildResult: Notifying results by email.')
notificationManager.notifyEmail(data)
}
Expand Down Expand Up @@ -135,12 +135,12 @@ def customisedEmail(String email) {
}
}
if (suffix?.trim()) {
return email.replace('@', "+${suffix}@")
return [email.replace('@', "+${suffix}@")]
} else {
return email
return [email]
}
}
return ''
return []
}

def isGitCheckoutIssue() {
Expand Down
12 changes: 10 additions & 2 deletions vars/opbeansPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def call(Map pipelineParams) {
when {
anyOf {
branch 'master'
tag pattern: 'v\\d+\\.\\d+.*', comparator: 'REGEXP'
tag pattern: '(v\\d+\\.\\d+|@).*', comparator: 'REGEXP'
}
}
environment {
Expand All @@ -165,8 +165,16 @@ def call(Map pipelineParams) {
deleteDir()
unstash 'source'
dir(BASE_DIR){
// opbeans-frontend uses a different tag versioning
script {
if (env.VERSION.contains('@')) {
env.TAG = env.VERSION.replaceAll('.*@', 'agent-')
} else {
env.TAG = env.VERSION
}
}
dockerLogin(secret: "${DOCKERHUB_SECRET}", registry: 'docker.io')
sh "VERSION=${env.VERSION} make publish"
sh "VERSION=${env.TAG} make publish"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion vars/setupAPMGitEmail.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ def call(Map params = [:]) {
def flag = params.containsKey('global') ? (params.global ? '--global' : '') : ''
sh(label: 'Git config', script: """
git config ${flag} user.name apmmachine
git config ${flag} user.email 58790750+apmmachine@users.noreply.github.com
git config ${flag} user.email infra-root+apmmachine@elastic.co
""")
}

0 comments on commit 5ef3587

Please sign in to comment.