Skip to content

Commit

Permalink
Support version
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Oct 22, 2020
1 parent 4145032 commit ea2f814
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .ci/beats-tester.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pipeline {
def runBeatsTesterJob(Map args = [:]) {
def apm = args.get('apm', '')
def beats = args.get('beats', '')
def version = args.version

if (isUpstreamTrigger()) {
copyArtifacts(filter: 'beats-tester.properties',
Expand All @@ -105,15 +106,16 @@ def runBeatsTesterJob(Map args = [:]) {
def props = readProperties(file: 'beats-tester.properties')
apm = props.get('APM_URL_BASE', '')
beats = props.get('BEATS_URL_BASE', '')
version = props.get('VERSION', '8.0.0-SNAPSHOT')
}
if (apm?.trim() || beats?.trim()) {
build(job: env.BEATS_TESTER_JOB, propagate: false, wait: false,
parameters: [
string(name: 'APM_URL_BASE', value: apm),
string(name: 'BEATS_URL_BASE', value: beats),
string(name: 'VERSION', value: args.version)
string(name: 'VERSION', value: version)
])
} else {
build(job: env.BEATS_TESTER_JOB, propagate: false, wait: false, parameters: [ string(name: 'VERSION', value: args.version) ])
build(job: env.BEATS_TESTER_JOB, propagate: false, wait: false, parameters: [ string(name: 'VERSION', value: version) ])
}
}
11 changes: 8 additions & 3 deletions .ci/packaging.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ pipeline {
}
}
setEnvVar("GO_VERSION", readFile("${BASE_DIR}/.go-version").trim())
dir("${BASE_DIR}"){
setEnvVar('VERSION', sh(label: 'Get beat version', script: 'make get-version', returnStdout: true)?.trim())
}
stashV2(name: 'source', bucket: "${JOB_GCS_BUCKET_STASH}", credentialsId: "${JOB_GCS_CREDENTIALS}")
}
}
Expand Down Expand Up @@ -142,7 +145,9 @@ pipeline {
withGithubNotify(context: "Packaging Linux ${BEATS_FOLDER}") {
deleteDir()
release()
pushCIDockerImages()
dir("${BASE_DIR}") {
pushCIDockerImages()
}
}
prepareE2ETestForPackage("${BEATS_FOLDER}")
}
Expand Down Expand Up @@ -188,7 +193,7 @@ pipeline {
writeFile(file: 'beats-tester.properties', text: """## To be consumed by the beats-tester pipeline
COMMIT=${env.GIT_BASE_COMMIT}
BEATS_URL_BASE=https://storage.googleapis.com/beats-ci-artifacts/commits/${env.GIT_BASE_COMMIT}
VERSION=${env.JOB_BASE_NAME}-SNAPSHOT""")
VERSION=${env.VERSION}-SNAPSHOT""")
archiveArtifacts artifacts: 'beats-tester.properties'
}
}
Expand Down Expand Up @@ -217,7 +222,7 @@ def pushCIDockerImages(){
}

def tagAndPush(beatName){
def libbetaVer = sh(label: 'Get libbeat version', script: 'grep defaultBeatVersion ${BASE_DIR}/libbeat/version/version.go|cut -d "=" -f 2|tr -d \\"', returnStdout: true)?.trim()
def libbetaVer = sh(label: 'Get beat version', script: 'make get-version', returnStdout: true)?.trim()
def aliasVersion = ""
if("${env.SNAPSHOT}" == "true"){
aliasVersion = libbetaVer.substring(0, libbetaVer.lastIndexOf(".")) // remove third number in version
Expand Down
5 changes: 4 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ pipeline {
}
post {
success {
dir("${BASE_DIR}"){
setEnvVar('VERSION', sh(label: 'Get beat version', script: 'make get-version', returnStdout: true)?.trim())
}
writeFile(file: 'packaging.properties', text: """## To be consumed by the packaging pipeline
COMMIT=${env.GIT_BASE_COMMIT}
VERSION=${BRANCH_NAME}-SNAPSHOT""")
VERSION=${VERSION}-SNAPSHOT""")
archiveArtifacts artifacts: 'packaging.properties'
}
always {
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ python-env:
test-apm:
sh ./script/test_apm.sh

## get-version : Get the libbeat version
.PHONY: get-version
get-version:
@mage dumpVariables | grep 'beat_version' | cut -d"=" -f 2 | tr -d " "

### Packaging targets ####

## snapshot : Builds a snapshot release.
Expand Down

0 comments on commit ea2f814

Please sign in to comment.