Skip to content

Commit e585e01

Browse files
committed
Draft create
1 parent 747cb3f commit e585e01

18 files changed

Lines changed: 417 additions & 0 deletions

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
draft.toml
2+
charts/
3+
NOTICE
4+
LICENSE
5+
README.md

.helmignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
*.png
23+
24+
# known compile time folders
25+
target/
26+
node_modules/
27+
vendor/

Jenkinsfile

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
pipeline {
2+
agent {
3+
label "jenkins-python"
4+
}
5+
environment {
6+
ORG = 'gitcoinco'
7+
APP_NAME = 'web'
8+
CHARTMUSEUM_CREDS = credentials('jenkins-x-chartmuseum')
9+
}
10+
stages {
11+
stage('CI Build and push snapshot') {
12+
when {
13+
branch 'PR-*'
14+
}
15+
environment {
16+
PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER"
17+
PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase()
18+
HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase()
19+
}
20+
steps {
21+
container('python') {
22+
sh "python -m unittest"
23+
24+
sh 'export VERSION=$PREVIEW_VERSION && skaffold build -f skaffold.yaml'
25+
26+
27+
sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$PREVIEW_VERSION"
28+
}
29+
30+
dir ('./charts/preview') {
31+
container('python') {
32+
sh "make preview"
33+
sh "jx preview --app $APP_NAME --dir ../.."
34+
}
35+
}
36+
}
37+
}
38+
stage('Build Release') {
39+
when {
40+
branch 'master'
41+
}
42+
steps {
43+
container('python') {
44+
// ensure we're not on a detached head
45+
sh "git checkout master"
46+
sh "git config --global credential.helper store"
47+
48+
sh "jx step git credentials"
49+
// so we can retrieve the version in later steps
50+
sh "echo \$(jx-release-version) > VERSION"
51+
}
52+
dir ('./charts/web') {
53+
container('python') {
54+
sh "make tag"
55+
}
56+
}
57+
container('python') {
58+
sh "python -m unittest"
59+
60+
sh 'export VERSION=`cat VERSION` && skaffold build -f skaffold.yaml'
61+
62+
sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:\$(cat VERSION)"
63+
}
64+
}
65+
}
66+
stage('Promote to Environments') {
67+
when {
68+
branch 'master'
69+
}
70+
steps {
71+
dir ('./charts/web') {
72+
container('python') {
73+
sh 'jx step changelog --version v\$(cat ../../VERSION)'
74+
75+
// release the helm chart
76+
sh 'jx step helm release'
77+
78+
// promote through all 'Auto' promotion Environments
79+
sh 'jx promote -b --all-auto --timeout 1h --version \$(cat ../../VERSION)'
80+
}
81+
}
82+
}
83+
}
84+
}
85+
post {
86+
always {
87+
cleanWs()
88+
}
89+
}
90+
}

charts/preview/Chart.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
description: A Helm chart for Kubernetes
3+
icon: https://raw.githubusercontent.com/jenkins-x/jenkins-x-platform/master/images/python.png
4+
name: preview
5+
version: 0.1.0-SNAPSHOT

charts/preview/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
OS := $(shell uname)
2+
3+
preview:
4+
ifeq ($(OS),Darwin)
5+
sed -i "" -e "s/version:.*/version: $(PREVIEW_VERSION)/" Chart.yaml
6+
sed -i "" -e "s/version:.*/version: $(PREVIEW_VERSION)/" ../*/Chart.yaml
7+
sed -i "" -e "s/tag: .*/tag: $(PREVIEW_VERSION)/" values.yaml
8+
else ifeq ($(OS),Linux)
9+
sed -i -e "s/version:.*/version: $(PREVIEW_VERSION)/" Chart.yaml
10+
sed -i -e "s/version:.*/version: $(PREVIEW_VERSION)/" ../*/Chart.yaml
11+
sed -i -e "s|repository: .*|repository: $(DOCKER_REGISTRY)\/gitcoinco\/web|" values.yaml
12+
sed -i -e "s/tag: .*/tag: $(PREVIEW_VERSION)/" values.yaml
13+
else
14+
echo "platfrom $(OS) not supported to release from"
15+
exit -1
16+
endif
17+
echo " version: $(PREVIEW_VERSION)" >> requirements.yaml
18+
jx step helm build

charts/preview/requirements.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
dependencies:
3+
- alias: expose
4+
name: exposecontroller
5+
repository: https://chartmuseum.build.cd.jenkins-x.io
6+
version: 2.3.56
7+
- alias: cleanup
8+
name: exposecontroller
9+
repository: https://chartmuseum.build.cd.jenkins-x.io
10+
version: 2.3.56
11+
- alias: preview
12+
name: web
13+
repository: file://../web

charts/preview/values.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
expose:
3+
Annotations:
4+
helm.sh/hook: post-install,post-upgrade
5+
helm.sh/hook-delete-policy: hook-succeeded
6+
config:
7+
exposer: Ingress
8+
http: true
9+
tlsacme: false
10+
11+
cleanup:
12+
Args:
13+
- --cleanup
14+
Annotations:
15+
helm.sh/hook: pre-delete
16+
helm.sh/hook-delete-policy: hook-succeeded
17+
18+
preview:
19+
image:
20+
repository:
21+
tag:
22+
pullPolicy: IfNotPresent

charts/web/.helmignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj

charts/web/Chart.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
description: A Helm chart for Kubernetes
3+
name: web
4+
version: v0.1.0

charts/web/Makefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
CHART_REPO := http://jenkins-x-chartmuseum:8080
2+
CURRENT=$(pwd)
3+
NAME := web
4+
OS := $(shell uname)
5+
RELEASE_VERSION := $(shell cat ../../VERSION)
6+
7+
build: clean
8+
rm -rf requirements.lock
9+
helm dependency build
10+
helm lint
11+
12+
install: clean build
13+
helm install . --name ${NAME}
14+
15+
upgrade: clean build
16+
helm upgrade ${NAME} .
17+
18+
delete:
19+
helm delete --purge ${NAME}
20+
21+
clean:
22+
rm -rf charts
23+
rm -rf ${NAME}*.tgz
24+
25+
release: clean
26+
helm dependency build
27+
helm lint
28+
helm init --client-only
29+
helm package .
30+
curl --fail -u $(CHARTMUSEUM_CREDS_USR):$(CHARTMUSEUM_CREDS_PSW) --data-binary "@$(NAME)-$(shell sed -n 's/^version: //p' Chart.yaml).tgz" $(CHART_REPO)/api/charts
31+
rm -rf ${NAME}*.tgz%
32+
33+
tag:
34+
ifeq ($(OS),Darwin)
35+
sed -i "" -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml
36+
sed -i "" -e "s/tag: .*/tag: $(RELEASE_VERSION)/" values.yaml
37+
else ifeq ($(OS),Linux)
38+
sed -i -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml
39+
sed -i -e "s|repository: .*|repository: $(DOCKER_REGISTRY)\/gitcoinco\/web|" values.yaml
40+
sed -i -e "s/tag: .*/tag: $(RELEASE_VERSION)/" values.yaml
41+
else
42+
echo "platfrom $(OS) not supported to release from"
43+
exit -1
44+
endif
45+
git add --all
46+
git commit -m "release $(RELEASE_VERSION)" --allow-empty # if first release then no verion update is performed
47+
git tag -fa v$(RELEASE_VERSION) -m "Release version $(RELEASE_VERSION)"
48+
git push origin v$(RELEASE_VERSION)

0 commit comments

Comments
 (0)