Skip to content

Commit 9e50016

Browse files
authored
ci(jenkins): revert none agent (#572)
* Revert "ci(jenkins): the environment GIT_BASE_COMMIT is not accessible (#569)" This reverts commit 2562886. * Revert "ci(jenkins): avoid using the any agent to skip running in the master-worker (#568)" This reverts commit f99a65b.
1 parent 2562886 commit 9e50016

File tree

4 files changed

+54
-76
lines changed

4 files changed

+54
-76
lines changed

.ci/Jenkinsfile

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@
22
@Library('apm@current') _
33

44
import co.elastic.matrix.*
5-
import groovy.transform.Field
6-
7-
/**
8-
This is the git commit sha which it's required to be used in different stages.
9-
It does store the env GIT_SHA
10-
*/
11-
@Field def gitCommit
125

136
pipeline {
14-
agent none
7+
agent any
158
environment {
169
BASE_DIR="src/github.com/elastic/apm-agent-python"
1710
PIPELINE_LOG_LEVEL='INFO'
@@ -49,9 +42,6 @@ pipeline {
4942
deleteDir()
5043
gitCheckout(basedir: "${BASE_DIR}")
5144
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
52-
script {
53-
gitCommit = env.GIT_SHA
54-
}
5545
}
5646
}
5747
stage('Sanity checks') {
@@ -70,35 +60,36 @@ pipeline {
7060
docker.image('python:3.7-stretch').inside("-e PATH=${PATH}:${env.WORKSPACE}/bin"){
7161
dir("${BASE_DIR}"){
7262
// registry: '' will help to disable the docker login
73-
preCommit(commit: "${gitCommit}", junit: true, registry: '')
63+
preCommit(commit: "${GIT_BASE_COMMIT}", junit: true, registry: '')
7464
}
7565
}
7666
}
7767
}
7868
}
7969
}
80-
/**
81-
Execute unit tests.
82-
*/
83-
stage('Test') {
84-
options {
85-
timeout(time: 1, unit: 'HOURS')
86-
skipDefaultCheckout()
87-
}
88-
steps {
89-
withGithubNotify(context: 'Test', tab: 'tests') {
90-
deleteDir()
91-
unstash "source"
92-
dir("${BASE_DIR}"){
93-
script {
94-
def node = readYaml(file: '.ci/.jenkins_python.yml')
95-
def parallelTasks = [:]
96-
node['PYTHON_VERSION'].each{ version ->
97-
parallelTasks["${version}"] = generateStep(version)
98-
}
99-
parallel(parallelTasks)
100-
}
101-
}
70+
}
71+
}
72+
/**
73+
Execute unit tests.
74+
*/
75+
stage('Test') {
76+
agent { label 'linux && immutable' }
77+
options {
78+
timeout(time: 1, unit: 'HOURS')
79+
skipDefaultCheckout()
80+
}
81+
steps {
82+
withGithubNotify(context: 'Test', tab: 'tests') {
83+
deleteDir()
84+
unstash "source"
85+
dir("${BASE_DIR}"){
86+
script {
87+
def node = readYaml(file: '.ci/.jenkins_python.yml')
88+
def parallelTasks = [:]
89+
node['PYTHON_VERSION'].each{ version ->
90+
parallelTasks["${version}"] = generateStep(version)
91+
}
92+
parallel(parallelTasks)
10293
}
10394
}
10495
}
@@ -186,7 +177,7 @@ def generateStep(version){
186177
build(job: "apm-agent-python/apm-agent-python-downstream/${branch}",
187178
parameters: [
188179
string(name: 'PYTHON_VERSION', value: version),
189-
string(name: 'BRANCH_SPECIFIER', value: gitCommit),
180+
string(name: 'BRANCH_SPECIFIER', value: env.GIT_BASE_COMMIT),
190181
string(name: 'MERGE_TARGET', value: branch),
191182
],
192183
propagate: true,

.ci/downstreamTests.groovy

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ it is need as field to store the results of the tests.
1111
@Field def pythonTasksGen
1212

1313
pipeline {
14-
agent none
14+
agent any
1515
environment {
1616
REPO="[email protected]:elastic/apm-agent-python.git"
1717
BASE_DIR="src/github.com/elastic/apm-agent-python"
@@ -89,19 +89,17 @@ pipeline {
8989
}
9090
post {
9191
cleanup {
92-
node('linux && immutable') {
93-
script{
94-
if(pythonTasksGen?.results){
95-
writeJSON(file: 'results.json', json: toJSON(pythonTasksGen.results), pretty: 2)
96-
def mapResults = ["${params.agent_integration_test}": pythonTasksGen.results]
97-
def processor = new ResultsProcessor()
98-
processor.processResults(mapResults)
99-
archiveArtifacts allowEmptyArchive: true, artifacts: 'results.json,results.html', defaultExcludes: false
100-
catchError(buildResult: 'SUCCESS') {
101-
def datafile = readFile(file: "results.json")
102-
def json = getVaultSecret(secret: 'secret/apm-team/ci/apm-server-benchmark-cloud')
103-
sendDataToElasticsearch(es: json.data.url, data: datafile, restCall: '/jenkins-builds-test-results/_doc/')
104-
}
92+
script{
93+
if(pythonTasksGen?.results){
94+
writeJSON(file: 'results.json', json: toJSON(pythonTasksGen.results), pretty: 2)
95+
def mapResults = ["${params.agent_integration_test}": pythonTasksGen.results]
96+
def processor = new ResultsProcessor()
97+
processor.processResults(mapResults)
98+
archiveArtifacts allowEmptyArchive: true, artifacts: 'results.json,results.html', defaultExcludes: false
99+
catchError(buildResult: 'SUCCESS') {
100+
def datafile = readFile(file: "results.json")
101+
def json = getVaultSecret(secret: 'secret/apm-team/ci/apm-server-benchmark-cloud')
102+
sendDataToElasticsearch(es: json.data.url, data: datafile, restCall: '/jenkins-builds-test-results/_doc/')
105103
}
106104
}
107105
}

.ci/linting.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@Library('apm@current') _
33

44
pipeline {
5-
agent none
5+
agent any
66
options {
77
buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30'))
88
timestamps()

Jenkinsfile

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@ it is need as field to store the results of the tests.
1010
*/
1111
@Field def pythonTasksGen
1212

13-
/**
14-
This is the git commit sha which it's required to be used in different stages.
15-
It does store the env GIT_SHA
16-
*/
17-
@Field def gitCommit
18-
1913
pipeline {
20-
agent none
14+
agent any
2115
environment {
2216
REPO = 'apm-agent-python'
2317
BASE_DIR = "src/github.com/elastic/${env.REPO}"
@@ -62,9 +56,6 @@ pipeline {
6256
deleteDir()
6357
gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true)
6458
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
65-
script {
66-
gitCommit = env.GIT_SHA
67-
}
6859
}
6960
}
7061
stage('Sanity checks') {
@@ -83,7 +74,7 @@ pipeline {
8374
docker.image('python:3.7-stretch').inside("-e PATH=${PATH}:${env.WORKSPACE}/bin"){
8475
dir("${BASE_DIR}"){
8576
// registry: '' will help to disable the docker login
86-
preCommit(commit: "${gitCommit}", junit: true, registry: '')
77+
preCommit(commit: "${GIT_BASE_COMMIT}", junit: true, registry: '')
8778
}
8879
}
8980
}
@@ -156,10 +147,10 @@ pipeline {
156147
log(level: 'INFO', text: 'Launching Async ITs')
157148
build(job: env.ITS_PIPELINE, propagate: false, wait: false,
158149
parameters: [string(name: 'AGENT_INTEGRATION_TEST', value: 'Python'),
159-
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}"),
150+
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}"),
160151
string(name: 'GITHUB_CHECK_NAME', value: env.GITHUB_CHECK_ITS_NAME),
161152
string(name: 'GITHUB_CHECK_REPO', value: env.REPO),
162-
string(name: 'GITHUB_CHECK_SHA1', value: gitCommit)])
153+
string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT)])
163154
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('/','+')}")
164155
}
165156
}
@@ -205,19 +196,17 @@ pipeline {
205196
}
206197
post {
207198
cleanup {
208-
node('linux && immutable') {
209-
script{
210-
if(pythonTasksGen?.results){
211-
writeJSON(file: 'results.json', json: toJSON(pythonTasksGen.results), pretty: 2)
212-
def mapResults = ["${params.agent_integration_test}": pythonTasksGen.results]
213-
def processor = new ResultsProcessor()
214-
processor.processResults(mapResults)
215-
archiveArtifacts allowEmptyArchive: true, artifacts: 'results.json,results.html', defaultExcludes: false
216-
catchError(buildResult: 'SUCCESS') {
217-
def datafile = readFile(file: "results.json")
218-
def json = getVaultSecret(secret: 'secret/apm-team/ci/apm-server-benchmark-cloud')
219-
sendDataToElasticsearch(es: json.data.url, data: datafile, restCall: '/jenkins-builds-test-results/_doc/')
220-
}
199+
script{
200+
if(pythonTasksGen?.results){
201+
writeJSON(file: 'results.json', json: toJSON(pythonTasksGen.results), pretty: 2)
202+
def mapResults = ["${params.agent_integration_test}": pythonTasksGen.results]
203+
def processor = new ResultsProcessor()
204+
processor.processResults(mapResults)
205+
archiveArtifacts allowEmptyArchive: true, artifacts: 'results.json,results.html', defaultExcludes: false
206+
catchError(buildResult: 'SUCCESS') {
207+
def datafile = readFile(file: "results.json")
208+
def json = getVaultSecret(secret: 'secret/apm-team/ci/apm-server-benchmark-cloud')
209+
sendDataToElasticsearch(es: json.data.url, data: datafile, restCall: '/jenkins-builds-test-results/_doc/')
221210
}
222211
}
223212
}

0 commit comments

Comments
 (0)