Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 34 additions & 25 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
@Library('apm@current') _

import co.elastic.matrix.*
import groovy.transform.Field

/**
This is the git commit sha which it's required to be used in different stages.
It does store the env GIT_SHA
*/
@Field def gitCommit

pipeline {
agent none
Expand Down Expand Up @@ -42,6 +49,9 @@ pipeline {
deleteDir()
gitCheckout(basedir: "${BASE_DIR}")
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
script {
gitCommit = env.GIT_SHA
}
}
}
stage('Sanity checks') {
Expand All @@ -60,36 +70,35 @@ pipeline {
docker.image('python:3.7-stretch').inside("-e PATH=${PATH}:${env.WORKSPACE}/bin"){
dir("${BASE_DIR}"){
// registry: '' will help to disable the docker login
preCommit(commit: "${GIT_BASE_COMMIT}", junit: true, registry: '')
preCommit(commit: "${gitCommit}", junit: true, registry: '')
}
}
}
}
}
}
}
}
/**
Execute unit tests.
*/
stage('Test') {
agent { label 'linux && immutable' }
options {
timeout(time: 1, unit: 'HOURS')
skipDefaultCheckout()
}
steps {
withGithubNotify(context: 'Test', tab: 'tests') {
deleteDir()
unstash "source"
dir("${BASE_DIR}"){
script {
def node = readYaml(file: '.ci/.jenkins_python.yml')
def parallelTasks = [:]
node['PYTHON_VERSION'].each{ version ->
parallelTasks["${version}"] = generateStep(version)
}
parallel(parallelTasks)
/**
Execute unit tests.
*/
stage('Test') {
options {
timeout(time: 1, unit: 'HOURS')
skipDefaultCheckout()
}
steps {
withGithubNotify(context: 'Test', tab: 'tests') {
deleteDir()
unstash "source"
dir("${BASE_DIR}"){
script {
def node = readYaml(file: '.ci/.jenkins_python.yml')
def parallelTasks = [:]
node['PYTHON_VERSION'].each{ version ->
parallelTasks["${version}"] = generateStep(version)
}
parallel(parallelTasks)
}
}
}
}
}
Expand Down Expand Up @@ -177,7 +186,7 @@ def generateStep(version){
build(job: "apm-agent-python/apm-agent-python-downstream/${branch}",
parameters: [
string(name: 'PYTHON_VERSION', value: version),
string(name: 'BRANCH_SPECIFIER', value: env.GIT_BASE_COMMIT),
string(name: 'BRANCH_SPECIFIER', value: gitCommit),
string(name: 'MERGE_TARGET', value: branch),
],
propagate: true,
Expand Down
15 changes: 12 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ it is need as field to store the results of the tests.
*/
@Field def pythonTasksGen

/**
This is the git commit sha which it's required to be used in different stages.
It does store the env GIT_SHA
*/
@Field def gitCommit

pipeline {
agent none
environment {
Expand Down Expand Up @@ -56,6 +62,9 @@ pipeline {
deleteDir()
gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true)
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
script {
gitCommit = env.GIT_SHA
}
}
}
stage('Sanity checks') {
Expand All @@ -74,7 +83,7 @@ pipeline {
docker.image('python:3.7-stretch').inside("-e PATH=${PATH}:${env.WORKSPACE}/bin"){
dir("${BASE_DIR}"){
// registry: '' will help to disable the docker login
preCommit(commit: "${GIT_BASE_COMMIT}", junit: true, registry: '')
preCommit(commit: "${gitCommit}", junit: true, registry: '')
}
}
}
Expand Down Expand Up @@ -147,10 +156,10 @@ pipeline {
log(level: 'INFO', text: 'Launching Async ITs')
build(job: env.ITS_PIPELINE, propagate: false, wait: false,
parameters: [string(name: 'AGENT_INTEGRATION_TEST', value: 'Python'),
string(name: 'BUILD_OPTS', value: "--with-agent-python-flask --python-agent-package git+https://github.com/${env.CHANGE_FORK?.trim() ?: 'elastic' }/${env.REPO}.git@${env.GIT_BASE_COMMIT}"),
string(name: 'BUILD_OPTS', value: "--with-agent-python-flask --python-agent-package git+https://github.com/${env.CHANGE_FORK?.trim() ?: 'elastic' }/${env.REPO}.git@${gitCommit}"),
string(name: 'GITHUB_CHECK_NAME', value: env.GITHUB_CHECK_ITS_NAME),
string(name: 'GITHUB_CHECK_REPO', value: env.REPO),
string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT)])
string(name: 'GITHUB_CHECK_SHA1', value: gitCommit)])
githubNotify(context: "${env.GITHUB_CHECK_ITS_NAME}", description: "${env.GITHUB_CHECK_ITS_NAME} ...", status: 'PENDING', targetUrl: "${env.JENKINS_URL}search/?q=${env.ITS_PIPELINE.replaceAll('/','+')}")
}
}
Expand Down