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 2b318dfbb503..692c7ac0b618 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() + unstashV2(name: 'source', bucket: "${JOB_GCS_BUCKET}", credentialsId: "${JOB_GCS_CREDENTIALS}") + dir("${BASE_DIR}"){ + preCommit(commit: "${GIT_BASE_COMMIT}", junit: true) + } + } + } + } +} + def runBuildAndTest(Map args = [:]) { def filterStage = args.get('filterStage', 'mandatory') deleteDir()