This repository was archived by the owner on Oct 11, 2019. It is now read-only.
forked from phipleg/tensorflow-object-detector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
89 lines (71 loc) · 3.19 KB
/
Jenkinsfile
File metadata and controls
89 lines (71 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
ansiColor('xterm') {
node('master') {
deleteDir()
stage('Checkout') {
git branch: BRANCH_NAME, url: '[email protected]:just-football/tensorflow-object-detection-api', credentialsId: 'jenkins'
sh 'git checkout .'
}
COMMITER = sh(
script: 'git show --format="%aN <%aE>" dev | head -n 1',
returnStdout: true
).trim()
return;
} else {
echo "Previous commiter was $COMMITER - Building..."
}
stamp = System.currentTimeMillis()
stage('Build') {
sh "docker build -t $stamp ."
}
if (BRANCH_NAME =='dev') {
stage('Bump version') {
VERSION = sh(
script: 'docker run --rm -u $(id -u):$(id -g) -v "$PWD:/app" -v "$HOME/.git:/root/.git" -w "/app" node:latest npm version patch --no-git-tag-version',
returnStdout: true
).trim()
sshagent(['jenkins']) {
sh "git commit -am $VERSION"
sh "git tag $VERSION"
sh "git push --set-upstream origin dev"
sh "git push --tags"
}
echo "Version will be:$VERSION"
}
}
if (BRANCH_NAME == 'dev' || BRANCH_NAME == 'master') {
stage('Dependencies') {
sh 'curl -OL https://github.com/kubernetes/kops/releases/download/1.5.3/kops-linux-amd64'
sh 'mv kops-linux-amd64 kops'
sh 'chmod +x kops'
sh 'curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl'
sh 'chmod +x kubectl'
}
}
if (BRANCH_NAME == 'dev') {
stage('Deploy Dev') {
sh "source ./k8s/dev/env.sh && VERSION=$VERSION envsubst < k8s/deployment.yml > ./deployment.yml"
sh "aws ecr get-login --no-include-email --region eu-west-1 | sh -"
sh "docker tag $stamp 948156567635.dkr.ecr.eu-west-1.amazonaws.com/jf/zebra-object-detection:$VERSION"
sh "docker push 948156567635.dkr.ecr.eu-west-1.amazonaws.com/jf/zebra-object-detection:$VERSION"
withEnv(['KOPS_STATE_STORE=s3://jf-dev-k8s-state-store']) {
sh './kops export kubecfg k8s.dev.justfootball.io'
}
sh './kubectl apply -f ./deployment.yml'
}
}
if (BRANCH_NAME == 'master') {
stage('Deploy Live') {
VERSION = sh(
script: 'grep \'"version":\' package.json | cut -d\\" -f4',
returnStdout: true
).trim();
sh "source ./k8s/live/env.sh && VERSION=v$VERSION envsubst < k8s/deployment.yml > ./deployment.yml"
withEnv(['KOPS_STATE_STORE=s3://jf-k8s-state-store']) {
sh './kops export kubecfg k8s.justfootball.io'
}
sh './kubectl apply -f ./deployment.yml'
}
}
}
}