forked from InnovateUKGitHub/een-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
73 lines (54 loc) · 2.29 KB
/
Jenkinsfile
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
node {
env.WORKSPACE = pwd()
stage 'Code'
checkout scm
def commitSha = sho('git rev-parse --short HEAD | tee .out')
def projectName = sho('basename `git config --get remote.origin.url | grep -o "devops.innovateuk.org.*"` | tee .out')
projectName = projectName.substring(0, projectName.lastIndexOf('.'))
stage 'Npm'
sh "./build/steps/compile/npm.sh"
stage 'Gulp'
sh "./build/steps/compile/gulp.sh"
stage 'Composer'
sh "./build/steps/compile/composer.sh"
stage 'Unit Tests'
sh "./build/steps/test/phpunit.sh"
stage 'Package'
sh "./build/steps/compile/package.sh"
sh "./build/steps/deploy/credentials.sh"
def deployMethod = "rsync" //@todo load from base.properties (tarball / rsync)
def packageName = "${projectName}-${commitSha}" // e.g. baseproject-e43663b
if (deployMethod == ("tarball") ) {
sh "tar -zcf ${packageName}.tar.gz -C compiled ."
archive "${packageName}.tar.gz"
}
remoteDeploy('integration_v3', packageName, deployMethod, false)
// remoteDeploy('stage_brumear', packageName, deployMethod, true)
// if (env.BRANCH_NAME == ("master")) {
// remoteDeploy('production_degore', packageName, deployMethod, true)
// }
}
def remoteDeploy(String targetEnvironment, String packageName, String deployMethod, Boolean requireInput) {
stage "Upload to: ${targetEnvironment}"
if (requireInput) {
input "Deploy to ${targetEnvironment}?"
}
if (deployMethod == ("tarball")) {
sh "./build/steps/deploy/upload-by-package.sh ${targetEnvironment} ${packageName}"
} else {
sh "./build/steps/deploy/upload-by-rsync.sh ${targetEnvironment} ${packageName}"
}
stage "Deploy to: ${targetEnvironment}"
sh "./build/steps/deploy/remote-deploy.sh ${targetEnvironment} ${packageName} ${deployMethod}"
stage "Integration tests: ${targetEnvironment}"
build job: 'een-integration-tests', parameters: [[$class: 'StringParameterValue', name: 'APPLICATION_ENV', value: "${targetEnvironment}"]]
}
// sh-out - return the output from an sh command
String sho(String cmd) {
sh cmd
String out = readFile('.out').trim()
if (out) {
return out
}
error "failed to run: $cmd"
}