From 536c0080c7cf2e9d979cb643d47bef1ca3433eb4 Mon Sep 17 00:00:00 2001 From: Igor Dianov Date: Thu, 23 Jan 2020 02:09:44 -0800 Subject: [PATCH 1/5] fix(Jenkinsfile): Enabled publishing preview Docker image and Helm chart --- Jenkinsfile | 51 ++++++++++++++++++---------- charts/activiti-cloud-query/Makefile | 39 +++++++++++---------- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5b38809..010d65d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,8 @@ pipeline { environment { ORG = 'activiti' APP_NAME = 'activiti-cloud-query' - + CHARTMUSEUM_CREDS = credentials('jenkins-x-chartmuseum') + RELEASE_BRANCH = "master" GITHUB_CHARTS_REPO = "https://github.com/Activiti/activiti-cloud-helm-charts.git" GITHUB_HELM_REPO_URL = "https://activiti.github.io/activiti-cloud-helm-charts/" } @@ -22,41 +23,43 @@ pipeline { branch 'PR-*' } environment { - PREVIEW_VERSION = "7.1.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER" PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase() + VERSION = maven_project_version().replaceAll("SNAPSHOT","$BRANCH_NAME-$BUILD_NUMBER-SNAPSHOT") HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase() } steps { container('maven') { - sh "mvn versions:set -DnewVersion=$PREVIEW_VERSION" + sh "mvn versions:set -DnewVersion=$VERSION" sh "mvn install" - // sh "export VERSION=$PREVIEW_VERSION && skaffold build -f skaffold.yaml" + sh "export VERSION=$VERSION && skaffold build -f skaffold.yaml" // skip building docker image for now - // sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$PREVIEW_VERSION" - + // sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$VERSION" - //dir("./charts/$APP_NAME") { - // sh "make build" - //} + dir("./charts/$APP_NAME") { + sh "make prevew" + } } } } stage('Build Release') { when { - branch 'master' + branch "$RELEASE_BRANCH" + } + environment { + VERSION = jx_release_version() } steps { container('maven') { // ensure we're not on a detached head - sh "git checkout master" + sh "git checkout $RELEASE_BRANCH" sh "git config --global credential.helper store" sh "jx step git credentials" // so we can retrieve the version in later steps - sh "echo \$(jx-release-version) > VERSION" - sh "mvn versions:set -DnewVersion=\$(cat VERSION)" + sh "echo $VERSION > VERSION" + sh "mvn versions:set -DnewVersion=$VERSION" dir ("./charts/$APP_NAME") { retry(5) { @@ -65,20 +68,20 @@ pipeline { } sh 'mvn clean deploy' - sh 'export VERSION=`cat VERSION` && skaffold build -f skaffold.yaml' + sh "export VERSION=$VERSION && skaffold build -f skaffold.yaml" - sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:\$(cat VERSION)" + sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$VERSION" } } } stage('Promote to Environments') { when { - branch 'master' + branch "$RELEASE_BRANCH" } steps { container('maven') { dir ("./charts/$APP_NAME") { - //sh 'jx step changelog --version v\$(cat ../../VERSION)' + //sh 'jx step changelog --version v$VERSION' // release the helm chart sh 'make release' @@ -86,7 +89,7 @@ pipeline { sh 'make github' } // promote through all 'Auto' promotion Environments - // sh 'jx promote -b --all-auto --timeout 1h --version \$(cat ../../VERSION) --no-wait' + // sh "jx promote -b --all-auto --timeout 1h --version $VERSION --no-wait" sh 'jx step git credentials' sh 'sleep 10' retry(2) { @@ -112,3 +115,15 @@ pipeline { } } } + + def jx_release_version() { + container('maven') { + return sh( script: "echo \$(jx-release-version)", returnStdout: true).trim() + } + } + + def maven_project_version() { + container('maven') { + return sh( script: "echo \$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -f pom.xml)", returnStdout: true).trim() + } + } \ No newline at end of file diff --git a/charts/activiti-cloud-query/Makefile b/charts/activiti-cloud-query/Makefile index f9efccf..bbe19dc 100644 --- a/charts/activiti-cloud-query/Makefile +++ b/charts/activiti-cloud-query/Makefile @@ -1,10 +1,10 @@ -#CHART_REPO := http://jenkins-x-chartmuseum:8080 +CHART_REPO := $(or $(CHART_REPO),jenkins-x-chartmuseum:8080) CURRENT=$(shell pwd) NAME := activiti-cloud-query ORG := $(or $(ORG),activiti) APP_NAME := $(or $(APP_NAME),$(NAME)) OS := $(shell uname) -RELEASE_VERSION := $(shell cat ../../VERSION) +RELEASE_VERSION := $(or $(VERSION),$(shell cat ../../VERSION)) RELEASE_ARTIFACT := $(or $(RELEASE_ARTIFACT),$(APP_NAME)) GITHUB_CHARTS_REPO := $(or $(GITHUB_CHARTS_REPO),$(shell git config --get remote.origin.url)) @@ -18,6 +18,16 @@ build: clean helm lint helm install . --name ${NAME} --debug --dry-run +dry-run: + helm upgrade ${HELM_RELEASE} . --install --debug --dry-run + +$(NAME)-$(VERSION).tgz: build + helm package . + +package: $(NAME)-$(VERSION).tgz + +preview: version package dry-run release + install: build helm install . --name ${NAME} @@ -32,10 +42,9 @@ clean: rm -rf charts rm -rf ${NAME}*.tgz -release: build - helm package . -# curl -u $(CHARTMUSEUM_CREDS_USR):$(CHARTMUSEUM_CREDS_PSW) --data-binary "@$(NAME)-$(shell sed -n 's/^version: //p' Chart.yaml).tgz" $(CHART_REPO)/api/charts -# rm -rf ${NAME}*.tgz% +release: package + curl -u $(CHARTMUSEUM_CREDS_USR):$(CHARTMUSEUM_CREDS_PSW) --data-binary "@$(NAME)-$(VERSION).tgz" $(CHART_REPO)/api/charts + rm -rf ${NAME}*.tgz% github: $(eval GITHUB_CHARTS_DIR := $(shell basename $(GITHUB_CHARTS_REPO) .git)) @@ -50,18 +59,12 @@ github: git push origin "$(GITHUB_CHARTS_BRANCH)" rm -rf $(GITHUB_CHARTS_DIR) -tag: -ifeq ($(OS),Darwin) - sed -i "" -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml - sed -i "" -e "s/tag: .*/tag: $(RELEASE_VERSION)/" values.yaml -else ifeq ($(OS),Linux) - sed -i -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml - sed -i -e "s|repository: .*|repository: $(DOCKER_REGISTRY)/$(ORG)/$(APP_NAME)|" values.yaml - sed -i -e "s/tag: .*/tag: $(RELEASE_VERSION)/" values.yaml -else - echo "platfrom $(OS) not supported to release from" - exit -1 -endif +version: + sed -i -e "s/version:.*/version: $(VERSION)/" Chart.yaml + sed -i -e "s|repository: .*|repository: $(DOCKER_REGISTRY)/$(ORG)/$(NAME)|" values.yaml + sed -i -e "s/tag: .*/tag: $(VERSION)/" values.yaml + +tag: version git add --all git commit -m "release $(RELEASE_VERSION)" --allow-empty # if first release then no verion update is performed git tag -fa v$(RELEASE_VERSION) -m "Release version $(RELEASE_VERSION)" From 72caf3e62ecc48492c6483cec0c6cc908f910ce1 Mon Sep 17 00:00:00 2001 From: Igor Dianov Date: Thu, 23 Jan 2020 02:11:12 -0800 Subject: [PATCH 2/5] fix(version): update activiti-cloud-query-service to 7.1.0-PR-402-1-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f2dc6d0..af62047 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ HEAD - 7.1.227 + 7.1.0-PR-402-1-SNAPSHOT From 587be5cf8e5dd7734353ead75e4f862a229c652e Mon Sep 17 00:00:00 2001 From: Igor Dianov Date: Thu, 23 Jan 2020 02:45:17 -0800 Subject: [PATCH 3/5] fix(Makefile): Corrected RELEASE_VERSION variable name --- charts/activiti-cloud-query/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/activiti-cloud-query/Makefile b/charts/activiti-cloud-query/Makefile index bbe19dc..433d438 100644 --- a/charts/activiti-cloud-query/Makefile +++ b/charts/activiti-cloud-query/Makefile @@ -21,10 +21,10 @@ build: clean dry-run: helm upgrade ${HELM_RELEASE} . --install --debug --dry-run -$(NAME)-$(VERSION).tgz: build +$(NAME)-$(RELEASE_VERSION).tgz: build helm package . -package: $(NAME)-$(VERSION).tgz +package: $(NAME)-$(RELEASE_VERSION).tgz preview: version package dry-run release @@ -43,7 +43,7 @@ clean: rm -rf ${NAME}*.tgz release: package - curl -u $(CHARTMUSEUM_CREDS_USR):$(CHARTMUSEUM_CREDS_PSW) --data-binary "@$(NAME)-$(VERSION).tgz" $(CHART_REPO)/api/charts + curl -u $(CHARTMUSEUM_CREDS_USR):$(CHARTMUSEUM_CREDS_PSW) --data-binary "@$(NAME)-$(RELEASE_VERSION).tgz" $(CHART_REPO)/api/charts rm -rf ${NAME}*.tgz% github: From 2ea3693137011360b23adff7eefeabac689d7da8 Mon Sep 17 00:00:00 2001 From: Igor Dianov Date: Thu, 23 Jan 2020 02:50:37 -0800 Subject: [PATCH 4/5] fix(Jenkinsfile): Corrected typo --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 010d65d..d0bd844 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,7 +38,7 @@ pipeline { // sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$VERSION" dir("./charts/$APP_NAME") { - sh "make prevew" + sh "make preview" } } } From 1042985919b4249aab77f5338f1bf9c1f8616664 Mon Sep 17 00:00:00 2001 From: Igor Dianov Date: Thu, 23 Jan 2020 09:04:03 -0800 Subject: [PATCH 5/5] fix(version): update query-service to 7.1.0-PR-402-2-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index af62047..c71683d 100755 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ HEAD - 7.1.0-PR-402-1-SNAPSHOT + 7.1.0-PR-402-2-SNAPSHOT