-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile
More file actions
120 lines (114 loc) · 3.45 KB
/
Copy pathJenkinsfile
File metadata and controls
120 lines (114 loc) · 3.45 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
library('pipeline-library@bugfix/durable-task-workaround')
pipeline {
options { timestamps() }
agent any
environment {
SERVICE = 'deployer'
GITHUB_KEY = 'Deployer'
GITHUB_URL = 'git@github.com:RightBrain-Networks/deployer.git'
DOCKER_REGISTRY = '356438515751.dkr.ecr.us-east-1.amazonaws.com'
}
stages {
stage('Version') {
steps {
runAutoSemver("rightbrainnetworks/auto-semver:latest")
}
post{
// Update Git with status of version stage.
success {
updateGithubCommitStatus(GITHUB_URL, 'Passed version stage', 'SUCCESS', 'Version')
}
failure {
updateGithubCommitStatus(GITHUB_URL, 'Failed version stage', 'FAILURE', 'Version')
}
}
}
stage('Build') {
steps {
echo "Building ${env.SERVICE} docker image"
// Docker build flags are set via the getDockerBuildFlags() shared library.
sh "docker build ${getDockerBuildFlags()} -t ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.SEMVER_RESOLVED_VERSION} ."
sh "python setup.py sdist"
}
post{
// Update Git with status of build stage.
success {
updateGithubCommitStatus(GITHUB_URL, 'Passed build stage', 'SUCCESS', 'Build')
}
failure {
updateGithubCommitStatus(GITHUB_URL, 'Failed build stage', 'FAILURE', 'Build')
}
}
}
stage('Test') {
agent {
docker {
image "${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.SEMVER_RESOLVED_VERSION}"
args "--privileged"
}
}
steps
{
dir('deployer') {
sh 'python ./tests.py'
}
}
post{
// Update Git with status of test stage.
success {
updateGithubCommitStatus(GITHUB_URL, 'Passed test stage', 'SUCCESS', 'Test')
}
failure {
updateGithubCommitStatus(GITHUB_URL, 'Failed test stage', 'FAILURE', 'Test')
}
}
}
stage('Ship')
{
steps {
withEcr {
sh "docker push ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.SEMVER_RESOLVED_VERSION}"
script
{
if("${env.BRANCH_NAME}" == "development")
{
sh "docker tag ${env.DOCKER_REGISTRY}/${env.SERVICE}:${env.SEMVER_RESOLVED_VERSION} ${env.DOCKER_REGISTRY}/${env.SERVICE}:latest"
sh "docker push ${env.DOCKER_REGISTRY}/${env.SERVICE}:latest"
}
}
}
//Copy tar.gz file to s3 bucket
sh "aws s3 cp dist/${env.SERVICE}-*.tar.gz s3://rbn-ops-pkg-us-east-1/${env.SERVICE}/${env.SERVICE}-${env.SEMVER_RESOLVED_VERSION}.tar.gz"
}
}
stage('GitHub Release')
{
when {
expression {
"${env.SEMVER_STATUS}" == "0" && "${env.BRANCH_NAME}" == "development"
}
}
steps
{
echo "New version deteced!"
script
{
createGitHubRelease('rbn-opsGitHubToken', 'RightBrain-Networks/deployer', "${env.SEMVER_RESOLVED_VERSION}",
"${env.SEMVER_RESOLVED_VERSION}", ["deployer.tar.gz" : "dist/deployer-${env.SEMVER_NEW_VERSION}.tar.gz"])
}
}
}
stage('Push Version and Tag') {
steps {
echo "The current branch is ${env.BRANCH_NAME}."
gitPush(env.GITHUB_KEY, env.BRANCH_NAME, true)
}
}
}
post {
always {
removeDockerImages()
cleanWs()
}
}
}