-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
137 lines (114 loc) · 5.55 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!groovy
@Library(['github.com/cloudogu/[email protected]', 'github.com/cloudogu/[email protected]']) _
import com.cloudogu.ces.dogubuildlib.*
import com.cloudogu.ces.cesbuildlib.*
node('vagrant') {
String doguName = "nginx"
timestamps{
properties([
// Keep only the last x builds to preserve space
buildDiscarder(logRotator(numToKeepStr: '10')),
// Don't run concurrent builds for a branch, because they use the same workspace directory
disableConcurrentBuilds(),
// Parameter to activate dogu upgrade test on demand
parameters([
booleanParam(defaultValue: true, description: 'Enables cypress to record video of the integration tests.', name: 'EnableVideoRecording'),
booleanParam(defaultValue: true, description: 'Enables cypress to take screenshots of failing integration tests.', name: 'EnableScreenshotRecording'),
booleanParam(defaultValue: false, description: 'Test dogu upgrade from latest release or optionally from defined version below', name: 'TestDoguUpgrade'),
string(defaultValue: '', description: 'Old Dogu version for the upgrade test (optional; e.g. 3.23.0-1)', name: 'OldDoguVersionForUpgradeTest')
])
])
EcoSystem ecoSystem = new EcoSystem(this, "gcloud-ces-operations-internal-packer", "jenkins-gcloud-ces-operations-internal")
Git git = new Git(this, "cesmarvin")
git.committerName = 'cesmarvin'
git.committerEmail = '[email protected]'
GitFlow gitflow = new GitFlow(this, git)
GitHub github = new GitHub(this, git)
Changelog changelog = new Changelog(this)
stage('Checkout') {
checkout scm
}
stage('Lint') {
Dockerfile dockerfile = new Dockerfile(this)
dockerfile.lint()
}
stage('Check Markdown Links') {
Markdown markdown = new Markdown(this, "3.11.0")
markdown.check()
}
stage('Shellcheck'){
shellCheck('./resources/startup.sh ./nginx-build/build.sh')
}
try {
stage('Provision') {
ecoSystem.provision("/dogu")
}
stage('Setup') {
ecoSystem.loginBackend('cesmarvin-setup')
ecoSystem.setup()
}
stage('Build') {
ecoSystem.build("/dogu")
}
stage('Prepare integration tests') {
setIntegrationTestKeys(ecoSystem)
}
stage('Verify') {
ecoSystem.verify("/dogu")
}
stage('Wait for dependencies') {
timeout(15) {
ecoSystem.waitForDogu("cas")
}
}
stage('Integration tests') {
ecoSystem.runCypressIntegrationTests([cypressImage : "cypress/included:13.14.0",
enableVideo : params.EnableVideoRecording,
enableScreenshots: params.EnableScreenshotRecording])
}
if (params.TestDoguUpgrade != null && params.TestDoguUpgrade) {
stage('Upgrade dogu') {
ecoSystem.upgradeFromPreviousRelease(params.OldDoguVersionForUpgradeTest, doguName)
}
stage('Prepare integration tests - After Upgrade') {
setIntegrationTestKeys(ecoSystem)
ecoSystem.restartDogu("nginx")
}
stage('Wait for dependencies - After Upgrade') {
timeout(15) {
ecoSystem.waitForDogu("cas")
}
}
stage('Integration Tests - After Upgrade'){
// Run integration tests again to verify that the upgrade was successful
ecoSystem.runCypressIntegrationTests([cypressImage : "cypress/included:13.14.0",
enableVideo : params.EnableVideoRecording,
enableScreenshots: params.EnableScreenshotRecording])
}
}
if (gitflow.isReleaseBranch()) {
String releaseVersion = git.getSimpleBranchName()
stage('Finish Release') {
gitflow.finishRelease(releaseVersion)
}
stage('Push Dogu to registry') {
ecoSystem.push("/dogu")
}
stage ('Add Github-Release'){
github.createReleaseWithChangelog(releaseVersion, changelog)
}
}
} finally {
stage('Clean') {
ecoSystem.destroy()
}
}
}
}
void setIntegrationTestKeys(ecoSystem){
// static HTML config
ecoSystem.vagrant.ssh "sudo cp /dogu/integrationTests/privacy_policies.html /var/lib/ces/nginx/volumes/customhtml/"
ecoSystem.vagrant.ssh '''etcdctl set config/nginx/externals/privacy_policies '{\\"DisplayName\\":\\"Privacy Policies\\",\\"Description\\":\\"Contains information about the privacy policies enforced by our company\\",\\"Category\\":\\"Information\\",\\"URL\\":\\"/static/privacy_policies.html\\"}' '''
// etcd key for support entries
ecoSystem.vagrant.ssh '''etcdctl set /config/_global/disabled_warpmenu_support_entries '[\\"platform\\", \\"aboutCloudoguToken\\"]' '''
}