-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJenkinsfile
More file actions
76 lines (69 loc) · 2.8 KB
/
Jenkinsfile
File metadata and controls
76 lines (69 loc) · 2.8 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
node {
def phpBuilder = docker.image("scomm/php5.6:latest")
phpBuilder.pull()
// Test
try {
stage('Checkout') {
checkout scm
}
phpBuilder.inside("-v ${env.WORKSPACE}:/var/www/html -u 0:0 --entrypoint=''") {
withEnv(['SYMFONY_ENV=test', 'APP_ENV=test']) {
stage('Test Install') {
withCredentials([usernamePassword(credentialsId: 'github-login-scommbot', passwordVariable: 'TOKEN', usernameVariable: 'USER')]) {
sh "bin/composer config -g github-oauth.github.com $TOKEN"
}
sh "bin/composer install --no-interaction --prefer-dist --no-dev"
}
stage('Test Assets') {
sh "php app/console assetic:dump --env=test --no-debug"
}
// stage('Test Execute') {
// sh "bin/phpunit -c app --log-junit unitTestReport.xml"
// junit "unitTestReport.xml"
// }
}
}
} catch (e) {
slackSend color: 'bad', message: "Failed testing ${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|View>)"
throw e
}
if (env.BRANCH_NAME == 'master') {
// Build
try {
stage('Build Install') {
phpBuilder.inside("-v ${env.WORKSPACE}:/var/www/html -u 0:0 --entrypoint=''") {
withEnv(['SYMFONY_ENV=prod', 'APP_ENV=prod']) {
withCredentials([usernamePassword(credentialsId: 'github-login-scommbot', passwordVariable: 'TOKEN', usernameVariable: 'USER')]) {
sh "bin/composer config -g github-oauth.github.com $TOKEN"
}
sh "rm -rf vendor/*"
sh "bin/composer install --optimize-autoloader --no-interaction --prefer-dist --no-dev --no-scripts"
}
}
}
stage('Build Container') {
phpBuilder = docker.build("olytics:v${env.BUILD_NUMBER}", ".")
}
} catch (e) {
slackSend color: 'bad', message: "Failed building ${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|View>)"
throw e
}
// Deploy
try {
stage('Deploy Image') {
docker.withRegistry('https://664537616798.dkr.ecr.us-east-1.amazonaws.com', 'ecr:us-east-1:aws-jenkins-login') {
phpBuilder.push("v${env.BUILD_NUMBER}");
}
}
stage('Deploy Upgrade') {
rancher confirm: true, credentialId: 'rancher', endpoint: 'https://rancher.as3.io/v2-beta', environmentId: '1a18', image: "664537616798.dkr.ecr.us-east-1.amazonaws.com/olytics:v${env.BUILD_NUMBER}", service: 'platform/olytics', environments: '', ports: '', timeout: 300
}
stage('Deploy Notify') {
slackSend color: 'good', message: "Finished deploying ${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|View>)"
}
} catch (e) {
slackSend color: 'bad', message: "Failed deploying ${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|View>)"
throw e
}
}
}