Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

fix(AAE-731): Build preview Query service Docker image and Helm chart #423

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 33 additions & 18 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
}
Expand All @@ -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 preview"
}
}
}
}
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) {
Expand All @@ -65,28 +68,28 @@ 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'
retry(5) {
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) {
Expand All @@ -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()
}
}
39 changes: 21 additions & 18 deletions charts/activiti-cloud-query/Makefile
Original file line number Diff line number Diff line change
@@ -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))
Expand All @@ -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)-$(RELEASE_VERSION).tgz: build
helm package .

package: $(NAME)-$(RELEASE_VERSION).tgz

preview: version package dry-run release

install: build
helm install . --name ${NAME}

Expand All @@ -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)-$(RELEASE_VERSION).tgz" $(CHART_REPO)/api/charts
rm -rf ${NAME}*.tgz%

github:
$(eval GITHUB_CHARTS_DIR := $(shell basename $(GITHUB_CHARTS_REPO) .git))
Expand All @@ -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)"
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<tag>HEAD</tag>
</scm>
<properties>
<activiti-cloud-query-service.version>7.1.227</activiti-cloud-query-service.version>
<activiti-cloud-query-service.version>7.1.0-PR-402-2-SNAPSHOT</activiti-cloud-query-service.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down