-
Notifications
You must be signed in to change notification settings - Fork 4
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
release process for opbeans #271
Changes from 15 commits
a47e26c
7131d09
b0df1a9
02a7e60
6a6536a
4bbf416
cb9f24c
e253d89
01a1d98
7aa5fe3
674aaec
6efa152
dd68175
a5478ce
3c17be1
6a8b485
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 |
---|---|---|
|
@@ -35,6 +35,11 @@ def call(Map pipelineParams) { | |
PIPELINE_LOG_LEVEL = 'INFO' | ||
PATH = "${env.PATH}:${env.WORKSPACE}/bin" | ||
HOME = "${env.WORKSPACE}" | ||
DOCKER_REGISTRY_SECRET = 'secret/apm-team/ci/docker-registry/prod' | ||
REGISTRY = 'docker.elastic.co' | ||
STAGING_IMAGE = "${env.REGISTRY}/observability-ci" | ||
GITHUB_CHECK_ITS_NAME = 'Integration Tests' | ||
ITS_PIPELINE = 'apm-integration-tests-selector-mbp/master' | ||
} | ||
options { | ||
timeout(time: 1, unit: 'HOURS') | ||
|
@@ -47,7 +52,7 @@ def call(Map pipelineParams) { | |
quietPeriod(10) | ||
} | ||
triggers { | ||
issueCommentTrigger('(?i).*(?:jenkins\\W+)?run\\W+(?:the\\W+)?tests(?:\\W+please)?.*') | ||
issueCommentTrigger('(?i).*jenkins\\W+run\\W+(?:the\\W+)?tests(?:\\W+please)?.*') | ||
} | ||
stages { | ||
/** | ||
|
@@ -83,7 +88,7 @@ def call(Map pipelineParams) { | |
deleteDir() | ||
unstash 'source' | ||
dir(BASE_DIR){ | ||
sh "make test" | ||
sh 'make test' | ||
} | ||
} | ||
} | ||
|
@@ -95,23 +100,24 @@ def call(Map pipelineParams) { | |
} | ||
} | ||
} | ||
stage('Release') { | ||
agent { label 'linux && immutable' } | ||
when { | ||
branch 'master' | ||
beforeAgent true | ||
} | ||
stage('Staging') { | ||
steps { | ||
withGithubNotify(context: 'Release') { | ||
withGithubNotify(context: 'Staging') { | ||
deleteDir() | ||
unstash 'source' | ||
dir(BASE_DIR){ | ||
dockerLogin(secret: "${DOCKERHUB_SECRET}", registry: 'docker.io') | ||
sh "VERSION=latest make publish" | ||
dockerLogin(secret: "${DOCKER_REGISTRY_SECRET}", registry: "${REGISTRY}") | ||
sh label: "push docker image to ${env.STAGING_IMAGE}/${env.REPO_NAME}", | ||
script: "VERSION=${env.GIT_BASE_COMMIT} IMAGE=${env.STAGING_IMAGE}/${env.REPO_NAME} make publish" | ||
} | ||
} | ||
} | ||
} | ||
stage('Integration Tests') { | ||
steps { | ||
runBuildITs("${env.REPO_NAME}", "${env.STAGING_IMAGE}/${env.REPO_NAME}") | ||
} | ||
} | ||
stage('Downstream') { | ||
when { | ||
allOf { | ||
|
@@ -128,6 +134,39 @@ def call(Map pipelineParams) { | |
} | ||
} | ||
} | ||
stage('Release') { | ||
when { | ||
anyOf { | ||
branch 'master' | ||
tag pattern: 'v\\d+\\.\\d+.*', comparator: 'REGEXP' | ||
} | ||
} | ||
environment { | ||
VERSION = "${env.BRANCH_NAME.equals('master') ? 'latest' : 'agent-' + env.BRANCH_NAME}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Master branch got the docker tag |
||
} | ||
stages { | ||
stage('Publish') { | ||
steps { | ||
withGithubNotify(context: 'Publish') { | ||
deleteDir() | ||
unstash 'source' | ||
dir(BASE_DIR){ | ||
dockerLogin(secret: "${DOCKERHUB_SECRET}", registry: 'docker.io') | ||
sh "VERSION=${env.VERSION} make publish" | ||
} | ||
} | ||
} | ||
} | ||
stage('Release Notes') { | ||
when { | ||
expression { return false } | ||
} | ||
steps { | ||
echo 'TBD' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
|
@@ -136,3 +175,42 @@ def call(Map pipelineParams) { | |
} | ||
} | ||
} | ||
|
||
def runBuildITs(String repo, String stagingDockerImage) { | ||
build(job: env.ITS_PIPELINE, propagate: waitIfNotPR(), | ||
wait: env.CHANGE_ID?.trim() ? false : true, | ||
parameters: [string(name: 'AGENT_INTEGRATION_TEST', value: 'Opbeans'), | ||
string(name: 'BUILD_OPTS', value: "${generateBuildOpts(repo, stagingDockerImage)}"), | ||
string(name: 'GITHUB_CHECK_NAME', value: env.GITHUB_CHECK_ITS_NAME), | ||
string(name: 'GITHUB_CHECK_REPO', value: repo), | ||
string(name: 'GITHUB_CHECK_SHA1', value: env.GIT_BASE_COMMIT)]) | ||
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('/','+')}") | ||
} | ||
|
||
def generateBuildOpts(String repo, String stagingDockerImage) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the method in charge to facilitate what options are required to trigger the APM ITs. |
||
switch(repo) { | ||
case 'opbeans-go': | ||
opts = "--with-opbeans-go --opbeans-go-branch ${env.GIT_BASE_COMMIT} --opbeans-go-repo ${getForkedRepoOrElasticRepo(repo)}" | ||
break; | ||
case 'opbeans-java': | ||
opts = "--with-opbeans-java --opbeans-java-image ${stagingDockerImage} --opbeans-java-version ${env.GIT_BASE_COMMIT}" | ||
break; | ||
default: | ||
opts = '' | ||
break; | ||
} | ||
return opts.toString() | ||
} | ||
|
||
def waitIfNotPR() { | ||
return env.CHANGE_ID?.trim() ? false : true | ||
} | ||
|
||
def getForkedRepoOrElasticRepo(String repo) { | ||
// See https://issues.jenkins-ci.org/browse/JENKINS-58450 | ||
if (env.CHANGE_FORK?.contains('/')) { | ||
return env.CHANGE_FORK | ||
} else { | ||
return "${env.CHANGE_FORK?.trim() ?: 'elastic' }/${repo}".toString() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
force
jenkins
within the comment to be triggered. This is not related to this particular PR