From a6878e934ef66ac4915dc7ae116978e68514d36d Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 18 Oct 2021 14:55:40 +0100 Subject: [PATCH 1/2] [pre-commit] for linting merge-conflict, pipelines and JJBB --- .pre-commit-config.yaml | 12 ++++++++++++ Jenkinsfile | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000000..af7954520b93 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,12 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: check-merge-conflict + +- repo: https://github.com/elastic/apm-pipeline-library.git + rev: current + hooks: + - id: check-jenkins-pipelines + files: ^(.ci/(.*\.groovy|Jenkinsfile)|Jenkinsfile)$ + - id: check-jjbb diff --git a/Jenkinsfile b/Jenkinsfile index 14be5d331b60..ec224f901cc7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -203,10 +203,24 @@ def runLinting() { } } mapParallelTasks['default'] = { cmd(label: 'make check-default', script: 'make check-default') } - + mapParallelTasks['pre-commit'] = runPreCommit() parallel(mapParallelTasks) } +def runPreCommit() { + return { + withNode(labels: 'ubuntu-18 && immutable', forceWorkspace: true){ + withGithubNotify(context: 'Check pre-commit', tab: 'tests') { + deleteDir() + unstash 'source' + dir("${BASE_DIR}"){ + preCommit(commit: "${GIT_BASE_COMMIT}", junit: true) + } + } + } + } +} + def runBuildAndTest(Map args = [:]) { def filterStage = args.get('filterStage', 'mandatory') deleteDir() From d7796c7ea342222a71e74e750b0410d9455802ab Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 18 Oct 2021 15:15:34 +0100 Subject: [PATCH 2/2] use stashv2 and unstashv2 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ec224f901cc7..dd17073bc9fc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -212,7 +212,7 @@ def runPreCommit() { withNode(labels: 'ubuntu-18 && immutable', forceWorkspace: true){ withGithubNotify(context: 'Check pre-commit', tab: 'tests') { deleteDir() - unstash 'source' + unstashV2(name: 'source', bucket: "${JOB_GCS_BUCKET}", credentialsId: "${JOB_GCS_CREDENTIALS}") dir("${BASE_DIR}"){ preCommit(commit: "${GIT_BASE_COMMIT}", junit: true) }