Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

2.0 pipeline steps for beats #689

Merged
merged 46 commits into from
Sep 14, 2020
Merged

2.0 pipeline steps for beats #689

merged 46 commits into from
Sep 14, 2020

Conversation

v1v
Copy link
Member

@v1v v1v commented Jul 27, 2020

What does this PR do?

Specific steps for the beats 2.0 pipeline:

  • beatsWhen
  • beatsStages

That consume a YAML data structure such as:

when:
    branches: true             ## for all the branches
    changeset:                 ## when PR contains any of those entries in the changeset
        - "auditbeat"
        - "#metricbeat/beater" ## special token regarding the project dependency
        - '@ci'                ## special token regarding the changeset for the ci 
        - '@oss'               ## special token regarding the changeset for the oss 
    comments:                  ## when PR comment contains any of those entries
        - "/test auditbeat"
    labels:                    ## when PR labels matche any of those entries
        - "auditbeat"
    parameters:                ## when parameter was selected in the UI.
        - "auditbeat"
    tags: true                 ## for all the tags
    disabled: false
platform: "linux && ubuntu-16" ## default label for all the stages
stages:
    build:
        mage:
            - "mage build test"
    windows:
        mage:
            - "mage build unitTest"
        platforms:             ## override default labels in this specific stage.
            - "windows-2019"
            - "windows-2016"
        when:
            comments:
                - "/test auditbeat for windows"
            parameters:
                - "windows"
            disabled: true
## Changeset macros that are defined here and used in each specific 2.0 pipeline.
changeset:
    ci:
        - "^Jenkinsfile"
        - "^\\.ci/scripts/.*"
    oss:
        - "^go.mod"
        - "^libbeat/.*"
        - "^dev-tools/.*"
        - "^testing/.*"
    xpack:
        - "^go.mod"
        - "^libbeat/.*"
        - "^dev-tools/.*"
        - "^testing/.*"
        - "^x-pack/libbeat/.*" 
  • Prepare a mardown with the reason of the build to happen

Why is it important?

Simplify and reuse steps with some UT/ITs

Related issues

Caused elastic/beats#20104

Test

  • Markdown build reasons

image

  • beatsWhen

image

  • beatsStages

image

image

Tasks

  • Changeset when implementation
  • Set the closure with the right implementation to be used...
  • Cast class warning
    • expected to call org.codehaus.groovy.runtime.MethodClosure.call but wound up catching WorkflowScript.runCommand; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/.
    • cb7b894 changed the paradigm to use a class instead calling a pointer to a function. elastic/beats@a3da232 is the implementation of the class.

@apmmachine
Copy link
Contributor

apmmachine commented Jul 27, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #689 updated]

  • Start Time: 2020-09-14T10:57:52.314+0000

  • Duration: 6 min 14 sec

Test stats 🧪

Test Results
Failed 0
Passed 769
Skipped 18
Total 787

Steps errors

Expand to view the steps failures

  • Name: Archive JUnit-formatted test results
    • Description: [2020-09-14T11:00:54.991Z] Recording test results
      [2020-09-14T11:00:55.437Z] Failed to read /var/li

    • Duration: 0 min 0 sec

    • Start Time: 2020-09-14T11:00:54.987+0000

    • log

@v1v v1v marked this pull request as ready for review July 28, 2020 17:20
@v1v v1v self-assigned this Jul 28, 2020
@v1v v1v marked this pull request as draft July 28, 2020 17:20
@v1v v1v requested a review from a team July 28, 2020 17:20
@v1v v1v added the enhancement New feature or request label Jul 28, 2020
vars/beatsWhen.groovy Outdated Show resolved Hide resolved
vars/beatsWhen.groovy Outdated Show resolved Hide resolved
vars/beatsWhen.groovy Outdated Show resolved Hide resolved
vars/beatsWhen.groovy Outdated Show resolved Hide resolved
Copy link
Contributor

@cachedout cachedout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a very sensible and easy-to-understand approach. I like it. 💯

content?.stages?.each { stageName, value ->
def tempMapOfStages = [:]
if (value.containsKey('when')) {
if (beatsWhen(project: project, content: value.when)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the need for this nested if conditional. It seems like both L33 and L36 are the same call?

Copy link
Member Author

@v1v v1v Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one of the stages contain a when condition then it's required to evaluate it before building the stages, for instance:

stages:
  stageA:
     make: foo
  stageB:
     make: bar
     when:
        labels:
           - 'foo'

There are two stages (stageA and stageB) but stageB will be enabled only if the GitHub labels match with foo. L32 is the one in charge of this evaluation.

v1v added 13 commits July 30, 2020 09:28
…ibrary into feature/2.0-beats

* 'feature/2.0-beats' of github.com:elastic/apm-pipeline-library:
  [jjbb] beats mbp is not required in the apm-ci anymore (#690)
… to identify the stage, since STAGE_NAME env variable is not available any more when creating stages dynamically
* upstream/master:
  dockerLogin step with less verbose output (#691)
* 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
  ...
expected to call org.codehaus.groovy.runtime.MethodClosure.call but wound up catching WorkflowScript.runCommand; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/ was caused when using the this.& function pointer

This should help to avoid any kind of issues in the future in case the mismatch is forced to fail
@v1v
Copy link
Member Author

v1v commented Sep 3, 2020

Super-linter is broken, so this is unrelated to this PR

@v1v v1v marked this pull request as ready for review September 3, 2020 13:56
@v1v v1v requested a review from a team September 3, 2020 13:56
vars/beatsWhen.groovy Outdated Show resolved Hide resolved
v1v and others added 6 commits September 3, 2020 16:38
Co-authored-by: Manuel de la Peña <mdelapenya@gmail.com>
This reverts commit fa26c0f.
* upstream/master:
  super-linter seems to be broken (#709)
…ibrary into feature/2.0-beats

* 'feature/2.0-beats' of github.com:elastic/apm-pipeline-library:
  Update vars/beatsWhen.groovy
@v1v v1v merged commit 5d6a10d into master Sep 14, 2020
v1v referenced this pull request in v1v/apm-pipeline-library-backup Sep 15, 2020
* upstream/master:
  refactor: use env variables from the plugin (#426)
  docs: update CHANGELOG.md
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release v1.1.137
  Support multiple teams validation (#721)
  Fix isMemberOf data structure (#720)
  Revert "fix: run APM UI e2e tests for master branch only (#682)" (#713)
  docs: update CHANGELOG.md
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release v1.1.136
  2.0 pipeline steps for beats (#689)
  Remove timeout analyser and rebuild (#708)
  Support setEvnVar with booleans (#719)
  Move to fe/be config for apm-proxy (#718)
  Wrap checkout of spoa in dir (#717)
  chore: automate pickes (#714)
  New stage for apm-proxy (#712)
  docs: update CHANGELOG.md
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release v1.1.135
@v1v v1v deleted the feature/2.0-beats branch October 5, 2020 12:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants