-
Notifications
You must be signed in to change notification settings - Fork 207
[Jenkins] Go Agent Pipeline version 0 #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
44c5803
17396ee
26e3b41
0c77133
ece290f
4023751
ba1a532
c588d82
7fc5752
c211729
a31786f
67e94a9
fc40307
3aac405
a08ceca
b312193
99e31fd
d34a3e0
b14d3e2
556e499
09955f9
77d6af0
83adaec
06ca118
99f5628
397ffa5
8f5e104
4b3615f
e0d7b31
79316bb
b482928
f2b6139
27d5dc0
687823b
9179ac2
f3de2b9
41c9055
ecb46b8
e4de08d
df54a97
ebd794a
fe1b3e6
84fdbb2
5f46c49
59372f4
d53b105
d099649
bbdaa72
eaf0aa1
690be06
04921d8
a6506bc
f35e324
06f339b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,335 @@ | ||
| #!/usr/bin/env groovy | ||
|
|
||
| library identifier: 'apm@master', | ||
| retriever: modernSCM( | ||
| [$class: 'GitSCMSource', | ||
| credentialsId: 'f6c7695a-671e-4f4f-a331-acdce44ff9ba', | ||
| remote: 'git@github.com:elastic/apm-pipeline-library.git']) | ||
|
|
||
| pipeline { | ||
| agent any | ||
| environment { | ||
| HOME = "${env.HUDSON_HOME}" | ||
| BASE_DIR="src/go.elastic.co/apm" | ||
| JOB_GIT_CREDENTIALS = "f6c7695a-671e-4f4f-a331-acdce44ff9ba" | ||
| } | ||
| triggers { | ||
| cron('0 0 * * 1-5') | ||
| githubPush() | ||
| } | ||
| options { | ||
| timeout(time: 1, unit: 'HOURS') | ||
| buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: '2', daysToKeepStr: '30')) | ||
| timestamps() | ||
| preserveStashes() | ||
| ansiColor('xterm') | ||
| disableResume() | ||
| durabilityHint('PERFORMANCE_OPTIMIZED') | ||
| } | ||
| parameters { | ||
| string(name: 'branch_specifier', defaultValue: "", description: "the Git branch specifier to build (<branchName>, <tagName>, <commitId>, etc.)") | ||
| booleanParam(name: 'linux_ci', defaultValue: true, description: 'Enable Linux build') | ||
| booleanParam(name: 'test_ci', defaultValue: true, description: 'Enable test') | ||
| booleanParam(name: 'integration_test_ci', defaultValue: true, description: 'Enable run integgration test') | ||
| booleanParam(name: 'integration_test_pr_ci', defaultValue: true, description: 'Enable run integgration test') | ||
kuisathaverat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| booleanParam(name: 'integration_test_master_ci', defaultValue: true, description: 'Enable run integgration test') | ||
kuisathaverat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks') | ||
| booleanParam(name: 'doc_ci', defaultValue: true, description: 'Enable build documentation') | ||
| } | ||
|
|
||
| stages { | ||
| /** | ||
| Checkout the code and stash it, to use it on other stages. | ||
| */ | ||
| stage('Checkout') { | ||
| agent { label 'master || linux' } | ||
| environment { | ||
| PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" | ||
| GOPATH = "${env.WORKSPACE}" | ||
| } | ||
|
|
||
| steps { | ||
| withEnvWrapper() { | ||
| dir("${BASE_DIR}"){ | ||
| script{ | ||
| if(!branch_specifier){ | ||
| echo "Checkout SCM ${GIT_BRANCH}" | ||
| checkout scm | ||
| } else { | ||
| echo "Checkout ${branch_specifier}" | ||
| checkout([$class: 'GitSCM', branches: [[name: "${branch_specifier}"]], | ||
| doGenerateSubmoduleConfigurations: false, | ||
| extensions: [], | ||
| submoduleCfg: [], | ||
| userRemoteConfigs: [[credentialsId: "${JOB_GIT_CREDENTIALS}", | ||
| url: "${GIT_URL}"]]]) | ||
| } | ||
| env.JOB_GIT_COMMIT = getGitCommitSha() | ||
| env.JOB_GIT_URL = "${GIT_URL}" | ||
|
|
||
| github_enterprise_constructor() | ||
axw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| on_change{ | ||
| echo "build cause a change (commit or PR)" | ||
axw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| on_commit { | ||
| echo "build cause a commit" | ||
| } | ||
|
|
||
| on_merge { | ||
| echo "build cause a merge" | ||
| } | ||
|
|
||
| on_pull_request { | ||
| echo "build cause PR" | ||
| } | ||
| gitCreateTag() | ||
|
||
| } | ||
| } | ||
| stash allowEmpty: true, name: 'source' | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| Build on a linux environment. | ||
| */ | ||
| stage('build') { | ||
| agent { label 'linux' } | ||
| environment { | ||
| PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" | ||
| GOPATH = "${env.WORKSPACE}" | ||
| } | ||
|
|
||
| when { | ||
| beforeAgent true | ||
| environment name: 'linux_ci', value: 'true' | ||
| } | ||
| steps { | ||
| withEnvWrapper() { | ||
| unstash 'source' | ||
| dir("${BASE_DIR}"){ | ||
| sh """#!/bin/bash | ||
| make install check | ||
| """ | ||
| } | ||
| } | ||
| } | ||
| } | ||
| stage('Parallel stages') { | ||
| failFast true | ||
| parallel { | ||
| stage('test') { | ||
| agent { label 'linux' } | ||
| environment { | ||
| PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" | ||
| GOPATH = "${env.WORKSPACE}" | ||
| } | ||
|
|
||
| when { | ||
| beforeAgent true | ||
| environment name: 'test_ci', value: 'true' | ||
| } | ||
| steps { | ||
| withEnvWrapper() { | ||
| unstash 'source' | ||
| dir("${BASE_DIR}"){ | ||
| sh """#!/bin/bash | ||
| ./scripts/jenkins/test.sh | ||
| """ | ||
| codecov('apm-agent-go') | ||
axw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
| post { | ||
| always { | ||
| coverageReport("${BASE_DIR}/build") | ||
| junit(allowEmptyResults: true, | ||
| keepLongStdio: true, | ||
| testResults: "${BASE_DIR}/build/junit-*.xml") | ||
| } | ||
| } | ||
| } | ||
| stage('Benchmarks') { | ||
| agent { label 'linux' } | ||
| environment { | ||
| PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" | ||
| GOPATH = "${env.WORKSPACE}" | ||
| } | ||
|
|
||
| when { | ||
| beforeAgent true | ||
| allOf { | ||
| //branch 'master'; | ||
axw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| environment name: 'bench_ci', value: 'true' | ||
| } | ||
| } | ||
| steps { | ||
| withEnvWrapper() { | ||
| unstash 'source' | ||
| dir("${BASE_DIR}"){ | ||
| sh """#!/bin/bash | ||
| ./scripts/jenkins/bench.sh | ||
| """ | ||
| sendBenchmarks(file: 'build/bench.out') | ||
| } | ||
| } | ||
| } | ||
| post { | ||
| always { | ||
| junit(allowEmptyResults: true, | ||
| keepLongStdio: true, | ||
| testResults: "${BASE_DIR}/build/junit-*.xml") | ||
| } | ||
| } | ||
| } | ||
| stage('Docker tests') { | ||
| agent { label 'linux && docker' } | ||
| environment { | ||
| PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" | ||
| GOPATH = "${env.WORKSPACE}" | ||
| } | ||
|
|
||
| when { | ||
axw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| beforeAgent true | ||
| allOf { | ||
| //branch 'master'; | ||
axw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| environment name: 'integration_test_ci', value: 'true' | ||
| } | ||
| } | ||
| steps { | ||
| withEnvWrapper() { | ||
| unstash 'source' | ||
| dir("${BASE_DIR}"){ | ||
| sh """#!/bin/bash | ||
| ./scripts/jenkins/docker-test.sh | ||
| """ | ||
| codecov('apm-agent-go') | ||
| } | ||
| } | ||
| } | ||
| post { | ||
| always { | ||
| coverageReport("${BASE_DIR}/build") | ||
| junit(allowEmptyResults: true, | ||
| keepLongStdio: true, | ||
| testResults: "${BASE_DIR}/build/junit-*.xml") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| run Go integration test with the commit version on master branch. | ||
| */ | ||
| stage('Integration test master') { | ||
| agent { label 'linux' } | ||
| when { | ||
| beforeAgent true | ||
| allOf { | ||
| //branch 'master'; | ||
axw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| environment name: 'integration_test_master_ci', value: 'true' | ||
| } | ||
| } | ||
| steps { | ||
axw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| build( | ||
| job: 'apm-server-ci/apm-integration-test-axis-pipeline', | ||
| parameters: [ | ||
| string(name: 'BUILD_DESCRIPTION', value: "${BUILD_TAG}-INTEST"), | ||
| booleanParam(name: "go_Test", value: true), | ||
| booleanParam(name: "java_Test", value: false), | ||
| booleanParam(name: "ruby_Test", value: false), | ||
| booleanParam(name: "python_Test", value: false), | ||
| booleanParam(name: "nodejs_Test", value: false)], | ||
| wait: true, | ||
| propagate: true) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| run Go integration test with the commit version on a PR. | ||
| */ | ||
| stage('Integration test PR') { | ||
| agent { label 'linux' } | ||
| when { | ||
| beforeAgent true | ||
| allOf { | ||
| not { branch 'master' }; | ||
| environment name: 'integration_test_pr_ci', value: 'true' | ||
| } | ||
| } | ||
| steps { | ||
| build( | ||
| job: 'apm-server-ci/apm-integration-test-pipeline', | ||
| parameters: [ | ||
| string(name: 'BUILD_DESCRIPTION', value: "${BUILD_TAG}-INTEST"), | ||
| string(name: 'APM_AGENT_GO_PKG', value: "${BUILD_TAG}"), | ||
axw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| booleanParam(name: "go_Test", value: true), | ||
| booleanParam(name: "java_Test", value: false), | ||
| booleanParam(name: "ruby_Test", value: false), | ||
| booleanParam(name: "python_Test", value: false), | ||
| booleanParam(name: "nodejs_Test", value: false), | ||
| booleanParam(name: "kibana_Test", value: false), | ||
| booleanParam(name: "server_Test", value: false)], | ||
| wait: true, | ||
| propagate: true) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| stage('Documentation') { | ||
| agent { label 'linux' } | ||
| environment { | ||
| PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" | ||
| GOPATH = "${env.WORKSPACE}" | ||
| ELASTIC_DOCS = "${env.WORKSPACE}/elastic/docs" | ||
| } | ||
|
|
||
| when { | ||
| beforeAgent true | ||
| allOf { | ||
| //branch 'master'; | ||
| environment name: 'doc_ci', value: 'true' | ||
| } | ||
| } | ||
| steps { | ||
| withEnvWrapper() { | ||
| unstash 'source' | ||
| dir("${ELASTIC_DOCS}"){ | ||
| git "https://github.com/elastic/docs.git" | ||
| } | ||
| dir("${BASE_DIR}"){ | ||
| sh """#!/bin/bash | ||
| make docs | ||
| """ | ||
| } | ||
| } | ||
| } | ||
| post{ | ||
| success { | ||
| tar(file: "doc-files.tgz", archive: true, dir: "html", pathPrefix: "${BASE_DIR}/docs") | ||
| } | ||
| } | ||
| } | ||
| } | ||
| post { | ||
| always { | ||
| echo 'Post Actions' | ||
| gitDeleteTag() | ||
| } | ||
| success { | ||
| echo 'Success Post Actions' | ||
| } | ||
| aborted { | ||
| echo 'Aborted Post Actions' | ||
| } | ||
| failure { | ||
| echo 'Failure Post Actions' | ||
| //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${NOTIFY_TO}", sendToIndividuals: false]) | ||
| } | ||
| unstable { | ||
| echo 'Unstable Post Actions' | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/bin/bash | ||
| set -e | ||
| export GOPATH=$WORKSPACE | ||
| eval "$(gvm $GO_VERSION)" | ||
| go get -v -u github.com/jstemmer/go-junit-report | ||
| go get -v -t ./... | ||
|
|
||
| export OUT_FILE="build/bench.out" | ||
| mkdir -p build | ||
| go test -run=NONE -benchmem -bench=. ./... -v 2>&1 | tee ${OUT_FILE} | ||
| cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go-bench.xml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #!/bin/bash | ||
| set -ex | ||
| export GOPATH=$WORKSPACE | ||
| eval "$(gvm $GO_VERSION)" | ||
| go get -v -u github.com/jstemmer/go-junit-report | ||
| go get -v -u github.com/axw/gocov/gocov | ||
kuisathaverat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| go get -v -u github.com/matm/gocov-html | ||
| go get -v -u github.com/axw/gocov/... | ||
| go get -v -u github.com/AlekSi/gocov-xml | ||
|
|
||
| go get -v -t ./... | ||
|
|
||
| export COV_FILE="build/coverage.cov" | ||
| export OUT_FILE="build/test-report.out" | ||
| mkdir -p build | ||
|
|
||
| ./scripts/docker-compose-testing up -d --build | ||
| ./scripts/docker-compose-testing run -T --rm go-agent-tests make coverage | tee ${COV_FILE}.raw | ||
| echo "mode: atomic" > ${COV_FILE} | ||
kuisathaverat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| grep -v "mode\: atomic" ${COV_FILE}.raw >> ${COV_FILE} | ||
| gocov convert "${COV_FILE}" | gocov-html > build/coverage-apm-agent-go-docker-report.html | ||
| gocov convert "${COV_FILE}" | gocov-xml > build/coverage-apm-agent-go-docker-report.xml | ||
|
|
||
| ./scripts/docker-compose-testing run -T --rm go-agent-tests go test -race ./... -v 2>&1 | tee ${OUT_FILE} | ||
axw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go-docker.xml | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.