@@ -16,40 +16,21 @@ properties([
1616
1717// Generates a custom route file that contains the next version of Angular to test against
1818def generateNPMVersionRouteFile (Map args = new LinkedHashMap ()) {
19- // @angular/core's version is the one baked into the angular app
20- def nextVersion = sh(script : " npm view @angular/core@${ args.npm_tag} version" , returnStdout : true ). trim()
21-
22- echo " Target framework version: ${ nextVersion} "
23-
24- def routeFileContent = readJSON text : """
25- [{
26- "request": {
27- "method": "get",
28- "path": "/custom/integration/info"
29- },
30- "response": {
31- "status": 200,
32- "json": {
33- "version": "${ nextVersion} "
34- }
35- }
36- }]
37- """
38- writeJSON file : " ${ args.filePath} " , json : routeFileContent
19+ writeJSON file : " ${ args.filePath} " , json : args. content
3920}
4021
4122// Updates the Angular dependencies to the version specified by the npm tag
4223def updateDependenciesWithTag (Map args = new LinkedHashMap ()) {
43- String npm_tag = args. npm_tag
44- sh " yarn add @angular/core@${ npm_tag } @angular/animations@${ npm_tag } @angular/common@${ npm_tag } @angular/compiler@${ npm_tag } @angular/core@${ npm_tag } @angular/forms@${ npm_tag } @angular/platform-browser@${ npm_tag } @angular-devkit/build-angular@${ npm_tag } @angular/cli@${ npm_tag } @angular/compiler-cli@${ npm_tag } "
24+ String npmTag = args. npmTag ?: ' latest '
25+ sh " yarn add @angular/core@${ npmTag } @angular/animations@${ npmTag } @angular/common@${ npmTag } @angular/compiler@${ npmTag } @angular/core@${ npmTag } @angular/forms@${ npmTag } @angular/platform-browser@${ npmTag } @angular-devkit/build-angular@${ npmTag } @angular/cli@${ npmTag } @angular/compiler-cli@${ npmTag } "
4526}
4627
4728def runSmokeTests (Map args = new LinkedHashMap ()) {
4829 def platforms = args. platforms ?: [
4930 [ browser : " chrome" , provider : " lambdatest" ]
5031 ]
51- String customRouteFilePath = " ${ WORKSPACE} /version .json"
52- String additionalArgs = " --chunk 20 --totalTimeout 1800000 --singleTimeout 90000 --retries 3 --customRoutes ${ customRouteFilePath } "
32+ String routeFilePath = " ${ WORKSPACE} /customRoutes .json"
33+ String additionalArgs = " --chunk 20 --totalTimeout 1800000 --singleTimeout 90000 --retries 3 --customRoutes ${ routeFilePath } "
5334
5435 def processes = [:]
5536
@@ -77,8 +58,8 @@ def runSmokeTests(Map args = new LinkedHashMap()) {
7758 customArgs = customArgs + " --platformName \" ${ platform.os} \" "
7859 }
7960
80- generateNPMVersionRouteFile(npm_tag : args. npm_tag , filePath : customRouteFilePath )
81- updateDependenciesWithTag(npm_tag : args. npm_tag )
61+ generateNPMVersionRouteFile(content : args. routeContent , filePath : routeFilePath )
62+ updateDependenciesWithTag(npmTag : args. npmTag )
8263 bedrockTests(
8364 name : name,
8465 browser : platform. browser,
@@ -95,8 +76,8 @@ def runSmokeTests(Map args = new LinkedHashMap()) {
9576 def name = " headless-${ platform.browser}${ suffix} "
9677 processes[name] = {
9778 stage(" ${ name} " ) {
98- generateNPMVersionRouteFile(npm_tag : args. npm_tag , filePath : customRouteFilePath )
99- updateDependenciesWithTag(npm_tag : args. npm_tag )
79+ generateNPMVersionRouteFile(content : args. routeContent , filePath : routeFilePath )
80+ updateDependenciesWithTag(npmTag : args. npmTag )
10081 bedrockTests(
10182 name : name,
10283 browser : platform. browser,
@@ -114,6 +95,14 @@ def runSmokeTests(Map args = new LinkedHashMap()) {
11495 parallel processes
11596}
11697
98+ def notify (Map slackArgs ) {
99+ // In shared libraries, the `call` method is not in the pipeline CPS context. We need to call the `steps` object to safely call jenkins steps
100+ steps. retry(3 ) {
101+ return steps. slackSend([ username : ' TinyMCE Integration Smoke Test' , failOnError : true ] + slackArgs)
102+ }
103+ }
104+
105+
117106timestamps {
118107 tinyPods. node() {
119108 stage(' deps' ) {
@@ -125,7 +114,43 @@ timestamps {
125114 }
126115
127116 stage(' tests' ) {
128- runSmokeTests(npm_tag : params. NPM_TAG ?: ' latest' )
117+ String npmTag = params. NPM_TAG ?: ' latest'
118+ // @angular/core's version is the one baked into the angular app
119+ String nextVersion = sh(script : " npm view @angular/core@${ npmTag} version" , returnStdout : true ). trim()
120+ echo " The upcoming Angular version: ${ nextVersion} "
121+
122+ def customRouteContent = readJSON text : """
123+ [{
124+ "request": {
125+ "method": "get",
126+ "path": "/custom/integration/info"
127+ },
128+ "response": {
129+ "status": 200,
130+ "json": {
131+ "version": "${ nextVersion} "
132+ }
133+ }
134+ }]
135+ """
136+
137+ try {
138+ runSmokeTests(npmTag : npmTag, routeContent : customRouteContent)
139+ } catch (Exception e) {
140+ echo " Exception was caught: ${ e} "
141+ currentBuild. result = ' FAILURE'
142+ } finally {
143+ if (currentBuild. resultIsWorseOrEqualTo(' UNSTABLE' )) {
144+ def color = [' UNSTABLE' : ' warning' , ' FAILURE' : ' danger' ]
145+ def message = currentBuild. result == ' UNSTABLE' ? " Tests failed" : ' An unexpected error occurred while running tests'
146+
147+ notify(
148+ channel : ' #tiny-integrations-dev' ,
149+ color : color. get(currentBuild. result, ' #808080' ),
150+ message : " ${ env.JOB_NAME} against ${ nextVersion} failed: ${ message} (<${ env.BUILD_URL} |Open>)"
151+ )
152+ }
153+ }
129154 }
130155 }
131156}
0 commit comments