|
1 | | -#!groovy |
2 | | -@Library(['github.com/cloudogu/dogu-build-lib@v3.2.0', 'github.com/cloudogu/ces-build-lib@4.2.0']) _ |
3 | | -import com.cloudogu.ces.dogubuildlib.* |
4 | | -import com.cloudogu.ces.cesbuildlib.* |
5 | | - |
6 | | -node('vagrant') { |
7 | | - String doguName = "nginx" |
8 | | - timestamps{ |
9 | | - properties([ |
10 | | - // Keep only the last x builds to preserve space |
11 | | - buildDiscarder(logRotator(numToKeepStr: '10')), |
12 | | - // Don't run concurrent builds for a branch, because they use the same workspace directory |
13 | | - disableConcurrentBuilds(), |
14 | | - // Parameter to activate dogu upgrade test on demand |
15 | | - parameters([ |
16 | | - booleanParam(defaultValue: true, description: 'Enables cypress to record video of the integration tests.', name: 'EnableVideoRecording'), |
17 | | - booleanParam(defaultValue: true, description: 'Enables cypress to take screenshots of failing integration tests.', name: 'EnableScreenshotRecording'), |
18 | | - booleanParam(defaultValue: false, description: 'Test dogu upgrade from latest release or optionally from defined version below', name: 'TestDoguUpgrade'), |
19 | | - string(defaultValue: '', description: 'Old Dogu version for the upgrade test (optional; e.g. 3.23.0-1)', name: 'OldDoguVersionForUpgradeTest'), |
20 | | - choice(name: 'TrivySeverityLevels', choices: [TrivySeverityLevel.CRITICAL, TrivySeverityLevel.HIGH_AND_ABOVE, TrivySeverityLevel.MEDIUM_AND_ABOVE, TrivySeverityLevel.ALL], description: 'The levels to scan with trivy', defaultValue: TrivySeverityLevel.CRITICAL), |
21 | | - choice(name: 'TrivyStrategy', choices: [TrivyScanStrategy.UNSTABLE, TrivyScanStrategy.FAIL, TrivyScanStrategy.IGNORE], description: 'Define whether the build should be unstable, fail or whether the error should be ignored if any vulnerability was found.', defaultValue: TrivyScanStrategy.UNSTABLE), |
22 | | - ]) |
23 | | - ]) |
24 | | - |
25 | | - EcoSystem ecoSystem = new EcoSystem(this, "gcloud-ces-operations-internal-packer", "jenkins-gcloud-ces-operations-internal") |
26 | | - Git git = new Git(this, "cesmarvin") |
27 | | - git.committerName = 'cesmarvin' |
28 | | - git.committerEmail = 'cesmarvin@cloudogu.com' |
29 | | - GitFlow gitflow = new GitFlow(this, git) |
30 | | - GitHub github = new GitHub(this, git) |
31 | | - Changelog changelog = new Changelog(this) |
32 | | - |
33 | | - stage('Checkout') { |
34 | | - checkout scm |
35 | | - } |
36 | | - |
37 | | - stage('Lint') { |
38 | | - Dockerfile dockerfile = new Dockerfile(this) |
39 | | - dockerfile.lint() |
40 | | - } |
41 | | - |
42 | | - stage('Check Markdown Links') { |
43 | | - Markdown markdown = new Markdown(this, "3.11.0") |
44 | | - markdown.check() |
45 | | - } |
46 | | - |
47 | | - stage('Shellcheck'){ |
48 | | - shellCheck('./resources/startup.sh ./nginx-build/build.sh') |
49 | | - } |
50 | | - |
51 | | - try { |
52 | | - |
53 | | - stage('Provision') { |
54 | | - // change namespace to prerelease_namespace if in develop-branch |
55 | | - if (gitflow.isPreReleaseBranch()) { |
56 | | - sh "make prerelease_namespace" |
57 | | - } |
58 | | - ecoSystem.provision("/dogu") |
59 | | - } |
60 | | - |
61 | | - stage('Setup') { |
62 | | - ecoSystem.loginBackend('cesmarvin-setup') |
63 | | - ecoSystem.setup() |
64 | | - } |
65 | | - |
66 | | - stage('Build') { |
67 | | - // purge nginx from official namespace to prevent conflicts while building prerelease_official/nginx |
68 | | - if (gitflow.isPreReleaseBranch()) { |
69 | | - ecoSystem.purgeDogu("nginx") |
70 | | - } |
71 | | - ecoSystem.build("/dogu") |
72 | | - } |
73 | | - |
74 | | - stage('Trivy scan') { |
75 | | - ecoSystem.copyDoguImageToJenkinsWorker("/dogu") |
76 | | - Trivy trivy = new Trivy(this) |
77 | | - trivy.scanDogu(".", params.TrivySeverityLevels, params.TrivyStrategy) |
78 | | - trivy.saveFormattedTrivyReport(TrivyScanFormat.TABLE) |
79 | | - trivy.saveFormattedTrivyReport(TrivyScanFormat.JSON) |
80 | | - trivy.saveFormattedTrivyReport(TrivyScanFormat.HTML) |
81 | | - } |
82 | | - |
83 | | - stage('Prepare integration tests') { |
84 | | - setIntegrationTestKeys(ecoSystem) |
85 | | - } |
86 | | - |
87 | | - stage('Verify') { |
88 | | - ecoSystem.verify("/dogu") |
89 | | - } |
90 | | - |
91 | | - stage('Wait for dependencies') { |
92 | | - timeout(15) { |
93 | | - ecoSystem.waitForDogu("cas") |
94 | | - } |
95 | | - } |
96 | | - |
97 | | - stage('Integration tests') { |
98 | | - ecoSystem.runCypressIntegrationTests([cypressImage : "cypress/included:13.14.0", |
99 | | - enableVideo : params.EnableVideoRecording, |
100 | | - enableScreenshots: params.EnableScreenshotRecording]) |
101 | | - } |
102 | | - |
103 | | - if (params.TestDoguUpgrade != null && params.TestDoguUpgrade) { |
104 | | - stage('Upgrade dogu') { |
105 | | - ecoSystem.upgradeFromPreviousRelease(params.OldDoguVersionForUpgradeTest, doguName) |
106 | | - } |
107 | | - |
108 | | - stage('Prepare integration tests - After Upgrade') { |
109 | | - setIntegrationTestKeys(ecoSystem) |
110 | | - ecoSystem.restartDogu("nginx") |
111 | | - } |
112 | | - |
113 | | - stage('Wait for dependencies - After Upgrade') { |
114 | | - timeout(15) { |
115 | | - ecoSystem.waitForDogu("cas") |
116 | | - } |
117 | | - } |
118 | | - |
119 | | - stage('Integration Tests - After Upgrade'){ |
120 | | - // Run integration tests again to verify that the upgrade was successful |
121 | | - ecoSystem.runCypressIntegrationTests([cypressImage : "cypress/included:13.14.0", |
122 | | - enableVideo : params.EnableVideoRecording, |
123 | | - enableScreenshots: params.EnableScreenshotRecording]) |
124 | | - } |
125 | | - } |
126 | | - if (gitflow.isReleaseBranch()) { |
127 | | - String releaseVersion = git.getSimpleBranchName() |
128 | | - |
129 | | - stage('Finish Release') { |
130 | | - gitflow.finishRelease(releaseVersion) |
131 | | - } |
132 | | - |
133 | | - stage('Push Dogu to registry') { |
134 | | - ecoSystem.push("/dogu") |
135 | | - } |
| 1 | +@Library([ |
| 2 | + 'pipe-build-lib', |
| 3 | + 'ces-build-lib', |
| 4 | + 'dogu-build-lib' |
| 5 | +]) _ |
| 6 | + |
| 7 | +def pipe = new com.cloudogu.sos.pipebuildlib.DoguPipe(this, [ |
| 8 | + doguName : "nginx", |
| 9 | + shellScripts : ''' |
| 10 | + ./resources/startup.sh |
| 11 | + ./nginx-build/build.sh |
| 12 | + ''', |
| 13 | + checkMarkdown : true, |
| 14 | + cypressImage : 'cypress/included:13.14.0', |
| 15 | + runIntegrationTests : true, |
| 16 | + dependedDogus : ['cas'] |
| 17 | + |
| 18 | +]) |
| 19 | +com.cloudogu.ces.dogubuildlib.EcoSystem ecoSystem = pipe.ecoSystem |
| 20 | + |
| 21 | +pipe.setBuildProperties() |
| 22 | +pipe.addDefaultStages() |
| 23 | + |
| 24 | +pipe.insertStageAfter("trivy scan","Prepare integration tests") { |
| 25 | + setIntegrationTestKeys(ecoSystem) |
| 26 | +} |
136 | 27 |
|
137 | | - stage ('Add Github-Release'){ |
138 | | - github.createReleaseWithChangelog(releaseVersion, changelog) |
139 | | - } |
140 | | - } else if (gitflow.isPreReleaseBranch()) { |
141 | | - // push to registry in prerelease_namespace |
142 | | - stage('Push Prerelease Dogu to registry') { |
143 | | - ecoSystem.pushPreRelease("/dogu") |
144 | | - } |
145 | | - } |
146 | 28 |
|
147 | | - } finally { |
148 | | - stage('Clean') { |
149 | | - ecoSystem.destroy() |
150 | | - } |
151 | | - } |
152 | | - } |
| 29 | +pipe.insertStageAfter("upgrade dogu","Prepare integration tests") { |
| 30 | + setIntegrationTestKeys(ecoSystem) |
| 31 | + ecoSystem.restartDogu("nginx") |
153 | 32 | } |
154 | 33 |
|
| 34 | +pipe.run() |
| 35 | + |
155 | 36 | void setIntegrationTestKeys(ecoSystem){ |
156 | 37 | // static HTML config |
157 | 38 | ecoSystem.vagrant.ssh "sudo cp /dogu/integrationTests/privacy_policies.html /var/lib/ces/nginx/volumes/customhtml/" |
|
0 commit comments