Skip to content

Commit d187f85

Browse files
committed
Draft create
1 parent 9139dd6 commit d187f85

19 files changed

Lines changed: 461 additions & 0 deletions

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

OWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
approvers:
2+
- fourgates
3+
reviewers:
4+
- fourgates

OWNERS_ALIASES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
aliases:
2+
- fourgates
3+
best-approvers:
4+
- fourgates
5+
best-reviewers:
6+
- fourgates

charts/angular-docker/.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/angular-docker/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/d273e09/images/nodejs.png
4+
name: angular-docker
5+
version: 0.1.0-SNAPSHOT

charts/angular-docker/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 := angular-docker
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)\/fourgates\/angular-docker|" 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)

charts/angular-docker/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Javascript application
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
Get the application URL by running these commands:
3+
4+
kubectl get ingress {{ template "fullname" . }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
*/}}
13+
{{- define "fullname" -}}
14+
{{- $name := default .Chart.Name .Values.nameOverride -}}
15+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
16+
{{- end -}}

0 commit comments

Comments
 (0)