From c9216c99a7b47f0b027e00a6870b8a69fadad852 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 10:07:57 -0600 Subject: [PATCH 01/34] First attempt at a build --- Jenkinsfile | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..7bee1a2e --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,39 @@ +pipeline { + options { + timeout(time: 1, unit: 'HOURS') + } + agent { + kubernetes { + cloud 'kubernetes' + inheritFrom 'default' + yaml ''' + apiVersion: v1 + kind: Pod + spec: + containers: + - name: node + image: node:20 + command: + - cat + tty: true + ''' + } + } + + environment { + NO_COLOR = "false" + } + + stages { + stage('build') { + container('node') { + sh 'npm config set color false' + sh 'npm install' + sh 'npm run bootstrap' + sh 'npx swim-build' + } + } + + } +} + From f945020c422fc09eb538258f0fa9d6b56bcc2cfb Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 10:15:40 -0600 Subject: [PATCH 02/34] Put in a steps block. --- Jenkinsfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7bee1a2e..a1178bd1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,14 +26,15 @@ pipeline { stages { stage('build') { - container('node') { - sh 'npm config set color false' - sh 'npm install' - sh 'npm run bootstrap' - sh 'npx swim-build' + steps { + container('node') { + sh 'npm config set color false' + sh 'npm install' + sh 'npm run bootstrap' + sh 'npx swim-build' + } } } - } } From e560a4198545750548cb21a9fe745ca3005d88a0 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 10:27:40 -0600 Subject: [PATCH 03/34] First pass at manipulating the version. --- Jenkinsfile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index a1178bd1..f68c3628 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,16 @@ pipeline { } stages { + stage('version') { + steps { + def packageVersion = readJSON file: 'package.json' + echo packageVersion['version'] + } + + + + } + stage('build') { steps { container('node') { From a946e6cac0eb101e15a140ec46e9ef571560f745 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 10:28:37 -0600 Subject: [PATCH 04/34] Place script in a script block. --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f68c3628..af3c5001 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,8 +27,10 @@ pipeline { stages { stage('version') { steps { - def packageVersion = readJSON file: 'package.json' - echo packageVersion['version'] + script { + def packageVersion = readJSON file: 'package.json' + echo packageVersion['version'] + } } From 5eea1f30e7a8af6d9fcdd507478ce2bc3fecc768 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 10:48:44 -0600 Subject: [PATCH 05/34] Parse the version. --- Jenkinsfile | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index af3c5001..5260da7e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,5 @@ +import java.util.regex.Pattern + pipeline { options { timeout(time: 1, unit: 'HOURS') @@ -26,10 +28,31 @@ pipeline { stages { stage('version') { +// when { +// anyOf { +// branch 'main'; +// branch pattern: "^\\d+.\\d+.\\d+", comparator: "REGEXP" +// } +// } steps { script { - def packageVersion = readJSON file: 'package.json' - echo packageVersion['version'] + def packageContents = readJSON file: 'package.json' + def packageVersion = packageContents['version'] + def versionRegex = ~"^(\\d+)\\.(\\d+)\\.(\\d+)" + + def matcher =~ versionRegex + + if(!matcher.find()) { + fail("Could not determine the version from ${packageVersion}") + } + def major = Integer.parseInt(matcher[1]) + def minor = Integer.parseInt(matcher[1]) + def revision = Integer.parseInt(matcher[1]) + + echo "${major}.${minor}.${revision}" + + + } } From 38fbb1f6bd03991f98a51b052b5b23df892101a8 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 11:04:12 -0600 Subject: [PATCH 06/34] Parse the version. --- Jenkinsfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5260da7e..4f2f0f6e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -42,12 +42,15 @@ pipeline { def matcher =~ versionRegex - if(!matcher.find()) { + if(!matcher) { fail("Could not determine the version from ${packageVersion}") } + + + def major = Integer.parseInt(matcher[1]) - def minor = Integer.parseInt(matcher[1]) - def revision = Integer.parseInt(matcher[1]) + def minor = Integer.parseInt(matcher[2]) + def revision = Integer.parseInt(matcher[3]) echo "${major}.${minor}.${revision}" From 57bf44aebecd0470081d74172cd21c11a3c50500 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 11:06:14 -0600 Subject: [PATCH 07/34] Change regex syntax. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4f2f0f6e..4c60621e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,7 +40,7 @@ pipeline { def packageVersion = packageContents['version'] def versionRegex = ~"^(\\d+)\\.(\\d+)\\.(\\d+)" - def matcher =~ versionRegex + def matcher =~ /^(\d+)\.(\d+)\.(\d+)/ if(!matcher) { fail("Could not determine the version from ${packageVersion}") From 7c731cd2058c2fb5a8e6e6ab051c6ef5a8654935 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 11:10:37 -0600 Subject: [PATCH 08/34] Figuring out the regex syntax. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4c60621e..06d1658f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,7 +40,7 @@ pipeline { def packageVersion = packageContents['version'] def versionRegex = ~"^(\\d+)\\.(\\d+)\\.(\\d+)" - def matcher =~ /^(\d+)\.(\d+)\.(\d+)/ + def matcher = (packageVersion =~ /^(\d+)\.(\d+)\.(\d+)/) if(!matcher) { fail("Could not determine the version from ${packageVersion}") From 9032ca7b89fd34b7cb9fee1bb35127006e1d8726 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 11:12:28 -0600 Subject: [PATCH 09/34] Figuring out the regex syntax. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 06d1658f..dc5f16a8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { if(!matcher) { fail("Could not determine the version from ${packageVersion}") } - + echo matcher.toString() def major = Integer.parseInt(matcher[1]) From c3a85eb2d15c6c5377b83241c336385a87636e46 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 11:18:31 -0600 Subject: [PATCH 10/34] Figuring out the regex syntax. --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index dc5f16a8..8e31cbae 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,9 +48,9 @@ pipeline { echo matcher.toString() - def major = Integer.parseInt(matcher[1]) - def minor = Integer.parseInt(matcher[2]) - def revision = Integer.parseInt(matcher[3]) + def major = Integer.parseInt(matcher[0][1]) + def minor = Integer.parseInt(matcher[0][2]) + def revision = Integer.parseInt(matcher[0][3]) echo "${major}.${minor}.${revision}" From 12d431b0397960ecf41860ce0e5a1221de504914 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 11:21:41 -0600 Subject: [PATCH 11/34] created stage to read the version. --- Jenkinsfile | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8e31cbae..f5abd01f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,13 +27,36 @@ pipeline { } stages { - stage('version') { -// when { -// anyOf { -// branch 'main'; -// branch pattern: "^\\d+.\\d+.\\d+", comparator: "REGEXP" -// } -// } + stage('read-version') { + steps { + script { + def packageContents = readJSON file: 'package.json' + def packageVersion = packageContents['version'] + + def matcher = (packageVersion =~ /^(\d+)\.(\d+)\.(\d+)/) + + if(!matcher) { + fail("Could not determine the version from ${packageVersion}") + } + echo matcher.toString() + + //def means local variable. Removing means global. + version_major = Integer.parseInt(matcher[0][1]) + version_minor = Integer.parseInt(matcher[0][2]) + version_revision = Integer.parseInt(matcher[0][3]) + + echo "${version_major}.${version_minor}.${version_revision}" + } + } + } + + stage('modify-version') { + when { + anyOf { + branch 'main'; + branch pattern: "^\\d+.\\d+.\\d+", comparator: "REGEXP" + } + } steps { script { def packageContents = readJSON file: 'package.json' From fefa9027812698f75a493f645b4e2dc1e780be13 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 11:43:33 -0600 Subject: [PATCH 12/34] Added stages for generating version numbers in dev and production. --- Jenkinsfile | 57 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f5abd01f..1a590b4a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,3 @@ -import java.util.regex.Pattern - pipeline { options { timeout(time: 1, unit: 'HOURS') @@ -35,7 +33,7 @@ pipeline { def matcher = (packageVersion =~ /^(\d+)\.(\d+)\.(\d+)/) - if(!matcher) { + if (!matcher) { fail("Could not determine the version from ${packageVersion}") } echo matcher.toString() @@ -50,45 +48,56 @@ pipeline { } } + stage('generate-version-dev') { + when { + anyOf { + branch pattern: "^\\d+.\\d+.\\d+", comparator: "REGEXP"; + branch 'jenkins' + } + } + steps { + script { + def now = new Date() + def timestamp = now.format("yyMMddHHmmss", TimeZone.getTimeZone('UTC')) + version = "${version_major}.${version_minor}.${version_revision}-dev.${timestamp}" + } + } + } + + stage('generate-version-prod') { + when { + branch 'main'; + } + steps { + script { + version = "" + } + } + } + stage('modify-version') { when { anyOf { branch 'main'; + branch 'jenkins'; branch pattern: "^\\d+.\\d+.\\d+", comparator: "REGEXP" } } steps { script { def packageContents = readJSON file: 'package.json' - def packageVersion = packageContents['version'] - def versionRegex = ~"^(\\d+)\\.(\\d+)\\.(\\d+)" - - def matcher = (packageVersion =~ /^(\d+)\.(\d+)\.(\d+)/) - - if(!matcher) { - fail("Could not determine the version from ${packageVersion}") - } - echo matcher.toString() - - - def major = Integer.parseInt(matcher[0][1]) - def minor = Integer.parseInt(matcher[0][2]) - def revision = Integer.parseInt(matcher[0][3]) - - echo "${major}.${minor}.${revision}" - - + packageContents['version'] = version + writeJSON file: 'package.json', json: packageContents + archiveArtifacts artifacts: 'package.json' } } - - - } stage('build') { steps { container('node') { + sh 'npm config set progress false' sh 'npm config set color false' sh 'npm install' sh 'npm run bootstrap' From 97309ae3ca59d77b05346c47848daf216c92c1bc Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 11:50:39 -0600 Subject: [PATCH 13/34] Run on PR branches. --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1a590b4a..ac202f79 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,7 +52,7 @@ pipeline { when { anyOf { branch pattern: "^\\d+.\\d+.\\d+", comparator: "REGEXP"; - branch 'jenkins' + branch pattern: "PR-\\d+", comparator: "REGEXP" } } steps { @@ -79,8 +79,8 @@ pipeline { when { anyOf { branch 'main'; - branch 'jenkins'; - branch pattern: "^\\d+.\\d+.\\d+", comparator: "REGEXP" + branch pattern: "^\\d+.\\d+.\\d+", comparator: "REGEXP"; + branch pattern: "PR-\\d+", comparator: "REGEXP" } } steps { From c3959fba7a1b43c9bfc7d10cb4ca167885071535 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 11:59:48 -0600 Subject: [PATCH 14/34] Added stage to configure npm. Disable progress and colors. --- Jenkinsfile | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ac202f79..8e3cca3a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,11 +20,20 @@ pipeline { } } - environment { - NO_COLOR = "false" - } - stages { + stage('configure-npm') { + steps { + container('node') { + script { + def npmrc = """ +progress=false +color=never +""" + writeFile file: '.npmrc', text: npmrc + } + } + } + } stage('read-version') { steps { script { From b25b883eb71712a26ada4fa1d4d4ba6aae0db847 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 12:01:26 -0600 Subject: [PATCH 15/34] Echo the current version. --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 8e3cca3a..42c63eb9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,6 +69,7 @@ color=never def now = new Date() def timestamp = now.format("yyMMddHHmmss", TimeZone.getTimeZone('UTC')) version = "${version_major}.${version_minor}.${version_revision}-dev.${timestamp}" + echo "Setting version to '${version}'" } } } From 23e158fbeea54c3126063c96d188410d1cf9dee7 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 12:05:38 -0600 Subject: [PATCH 16/34] Pretty print the json. --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 42c63eb9..68ec9d7a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,7 +45,6 @@ color=never if (!matcher) { fail("Could not determine the version from ${packageVersion}") } - echo matcher.toString() //def means local variable. Removing means global. version_major = Integer.parseInt(matcher[0][1]) @@ -98,7 +97,7 @@ color=never def packageContents = readJSON file: 'package.json' packageContents['version'] = version - writeJSON file: 'package.json', json: packageContents + writeJSON file: 'package.json', json: packageContents, pretty: 4 archiveArtifacts artifacts: 'package.json' } } From b1284e55b60592ce54d36b992715a1c9c390f696 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 12:14:44 -0600 Subject: [PATCH 17/34] Removed config calls. --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 68ec9d7a..28fed312 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -106,8 +106,6 @@ color=never stage('build') { steps { container('node') { - sh 'npm config set progress false' - sh 'npm config set color false' sh 'npm install' sh 'npm run bootstrap' sh 'npx swim-build' From a05b743c4205d688cdca1c83cd815560fd8208d1 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 12:17:59 -0600 Subject: [PATCH 18/34] Output the the object type for version. --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 28fed312..219f0551 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -96,6 +96,7 @@ color=never script { def packageContents = readJSON file: 'package.json' packageContents['version'] = version + echo version.getClass() writeJSON file: 'package.json', json: packageContents, pretty: 4 archiveArtifacts artifacts: 'package.json' From 72faa71c00a21a662f22dcee84bbf5af38643b5e Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 12:19:20 -0600 Subject: [PATCH 19/34] Output the object type for version. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 219f0551..c3a69e3d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -96,7 +96,7 @@ color=never script { def packageContents = readJSON file: 'package.json' packageContents['version'] = version - echo version.getClass() + echo version.getClass().toString() writeJSON file: 'package.json', json: packageContents, pretty: 4 archiveArtifacts artifacts: 'package.json' From ed50366ca0fdfa9338d8cbc1df7eca6949c767fb Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 12:42:19 -0600 Subject: [PATCH 20/34] Convert version to a string. --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c3a69e3d..d7c1bced 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,7 @@ color=never version_minor = Integer.parseInt(matcher[0][2]) version_revision = Integer.parseInt(matcher[0][3]) - echo "${version_major}.${version_minor}.${version_revision}" + echo "Version read ${version_major}.${version_minor}.${version_revision}" } } } @@ -95,7 +95,7 @@ color=never steps { script { def packageContents = readJSON file: 'package.json' - packageContents['version'] = version + packageContents.version = version as String // Whoever came up with Groovy strings is an ass. echo version.getClass().toString() writeJSON file: 'package.json', json: packageContents, pretty: 4 From 0b43a864166a63f261261ed74b8650de4b81f92f Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 12:54:13 -0600 Subject: [PATCH 21/34] Added logic to update the dependencies. --- Jenkinsfile | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d7c1bced..dddbf663 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,12 +38,12 @@ color=never steps { script { def packageContents = readJSON file: 'package.json' - def packageVersion = packageContents['version'] + originalVersion = packageContents['version'] - def matcher = (packageVersion =~ /^(\d+)\.(\d+)\.(\d+)/) + def matcher = (originalVersion =~ /^(\d+)\.(\d+)\.(\d+)/) if (!matcher) { - fail("Could not determine the version from ${packageVersion}") + fail("Could not determine the version from ${originalVersion}") } //def means local variable. Removing means global. @@ -67,7 +67,7 @@ color=never script { def now = new Date() def timestamp = now.format("yyMMddHHmmss", TimeZone.getTimeZone('UTC')) - version = "${version_major}.${version_minor}.${version_revision}-dev.${timestamp}" + version = "${version_major}.${version_minor}.${version_revision}-dev.${timestamp}" as String // Whoever came up with Groovy strings is an ass. echo "Setting version to '${version}'" } } @@ -95,9 +95,22 @@ color=never steps { script { def packageContents = readJSON file: 'package.json' - packageContents.version = version as String // Whoever came up with Groovy strings is an ass. + packageContents.version = version as String echo version.getClass().toString() + def dependencies = packageContents['dependencies'] + def dependencyUpdates = [:] + + dependencies.each { + if entry.value == originalVersion { + dependencyUpdates.put(entry.key, version) + } + } + + if dependencyUpdates { + dependencies.putAll(dependencyUpdates) + } + writeJSON file: 'package.json', json: packageContents, pretty: 4 archiveArtifacts artifacts: 'package.json' } From 545f826daf61588a5a0d96a7536542a9f1ac0f0b Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 12:57:11 -0600 Subject: [PATCH 22/34] Archive the version number. --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index dddbf663..a10e1250 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -113,6 +113,8 @@ color=never writeJSON file: 'package.json', json: packageContents, pretty: 4 archiveArtifacts artifacts: 'package.json' + writeFile file: 'version.txt', text: version + archiveArtifacts artifacts: 'version.json' } } } From 5a1cf1393fa8827a2fbc769daec89b5f0b9cad1d Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 12:59:10 -0600 Subject: [PATCH 23/34] Corrected syntax. --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a10e1250..2e51fd25 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -102,12 +102,12 @@ color=never def dependencyUpdates = [:] dependencies.each { - if entry.value == originalVersion { + if (entry.value == originalVersion) { dependencyUpdates.put(entry.key, version) } } - if dependencyUpdates { + if (dependencyUpdates) { dependencies.putAll(dependencyUpdates) } From 393783dc9d9cb96151d5cd92a58ac0131b63c998 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 13:07:44 -0600 Subject: [PATCH 24/34] Corrected syntax. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2e51fd25..660f8f0a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -101,7 +101,7 @@ color=never def dependencies = packageContents['dependencies'] def dependencyUpdates = [:] - dependencies.each { + dependencies.each { entry -> if (entry.value == originalVersion) { dependencyUpdates.put(entry.key, version) } From 837710b19eb36af7bc70ea46f7fb6f599a3e95b6 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 13:09:10 -0600 Subject: [PATCH 25/34] Corrected file path. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 660f8f0a..4fe5bcb9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -114,7 +114,7 @@ color=never writeJSON file: 'package.json', json: packageContents, pretty: 4 archiveArtifacts artifacts: 'package.json' writeFile file: 'version.txt', text: version - archiveArtifacts artifacts: 'version.json' + archiveArtifacts artifacts: 'version.txt' } } } From 3bb32ea2fa397427aa40c74dee7e1aa121c0222b Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 13:34:35 -0600 Subject: [PATCH 26/34] Added call to archive artifacts. --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4fe5bcb9..d91ad377 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -96,7 +96,6 @@ color=never script { def packageContents = readJSON file: 'package.json' packageContents.version = version as String - echo version.getClass().toString() def dependencies = packageContents['dependencies'] def dependencyUpdates = [:] @@ -125,6 +124,9 @@ color=never sh 'npm install' sh 'npm run bootstrap' sh 'npx swim-build' + archiveArtifacts artifacts: "swim-core/**/dist/**/*.*" + archiveArtifacts artifacts: "swim-host/**/dist/**/*.*" + archiveArtifacts artifacts: "dist/**/*.*" } } } From f7782ab93be3987a61de6757aa3c2082236e62df Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 14:23:50 -0600 Subject: [PATCH 27/34] Multiple package files need to be updated. --- Jenkinsfile | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d91ad377..c02ede23 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -94,24 +94,28 @@ color=never } steps { script { - def packageContents = readJSON file: 'package.json' - packageContents.version = version as String + def packageFiles = findFiles glob: '**/package.json' + packageFiles.each { packageFile -> + def packageContents = readJSON file: packageFile + packageContents.version = version as String - def dependencies = packageContents['dependencies'] - def dependencyUpdates = [:] + def dependencies = packageContents['dependencies'] + def dependencyUpdates = [:] - dependencies.each { entry -> - if (entry.value == originalVersion) { - dependencyUpdates.put(entry.key, version) + dependencies.each { entry -> + if (entry.value == originalVersion) { + dependencyUpdates.put(entry.key, version) + } + } + + if (dependencyUpdates) { + dependencies.putAll(dependencyUpdates) } - } - if (dependencyUpdates) { - dependencies.putAll(dependencyUpdates) + writeJSON file: packageFile, json: packageContents, pretty: 4 + archiveArtifacts artifacts: packageFile } - writeJSON file: 'package.json', json: packageContents, pretty: 4 - archiveArtifacts artifacts: 'package.json' writeFile file: 'version.txt', text: version archiveArtifacts artifacts: 'version.txt' } From 55f7b0757c646dfbc434b19fee2d80c9124017d0 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 14:27:17 -0600 Subject: [PATCH 28/34] Ignore .idea and Jenkinsfile --- .npmignore | 2 ++ swim-core/.npmignore | 2 ++ swim-host/.npmignore | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.npmignore b/.npmignore index 117c988b..b17635fd 100644 --- a/.npmignore +++ b/.npmignore @@ -13,3 +13,5 @@ swim-*/ tsconfig.json tsdoc.json typedoc.json +.idea/ +Jenkinsfile \ No newline at end of file diff --git a/swim-core/.npmignore b/swim-core/.npmignore index 37f8eb00..c2484a55 100644 --- a/swim-core/.npmignore +++ b/swim-core/.npmignore @@ -11,3 +11,5 @@ swim-*/ tsconfig.json tsdoc.json typedoc.json +.idea/ +Jenkinsfile \ No newline at end of file diff --git a/swim-host/.npmignore b/swim-host/.npmignore index 37f8eb00..c2484a55 100644 --- a/swim-host/.npmignore +++ b/swim-host/.npmignore @@ -11,3 +11,5 @@ swim-*/ tsconfig.json tsdoc.json typedoc.json +.idea/ +Jenkinsfile \ No newline at end of file From 5b2674c5d114e0e10342e47f1f940a457ebb9818 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 14:29:09 -0600 Subject: [PATCH 29/34] Convert packageFile to a String. --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c02ede23..8c06664e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -96,7 +96,7 @@ color=never script { def packageFiles = findFiles glob: '**/package.json' packageFiles.each { packageFile -> - def packageContents = readJSON file: packageFile + def packageContents = readJSON file: "${packageFile}" packageContents.version = version as String def dependencies = packageContents['dependencies'] @@ -112,8 +112,8 @@ color=never dependencies.putAll(dependencyUpdates) } - writeJSON file: packageFile, json: packageContents, pretty: 4 - archiveArtifacts artifacts: packageFile + writeJSON file: "${packageFile}", json: packageContents, pretty: 4 + archiveArtifacts artifacts: "${packageFile}" } writeFile file: 'version.txt', text: version From 3f49224050f12851f633270e33cd6728326e5c35 Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 14:41:11 -0600 Subject: [PATCH 30/34] Update devDependencies as well. --- Jenkinsfile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8c06664e..ca6c25d6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -94,6 +94,8 @@ color=never } steps { script { + + def packageFiles = findFiles glob: '**/package.json' packageFiles.each { packageFile -> def packageContents = readJSON file: "${packageFile}" @@ -107,11 +109,25 @@ color=never dependencyUpdates.put(entry.key, version) } } - + if (dependencyUpdates) { dependencies.putAll(dependencyUpdates) } + def devDependencies = packageContents['devDependencies'] + def devDependencyUpdates = [:] + + devDependencies.each { entry -> + if (entry.value == originalVersion) { + devDependencyUpdates.put(entry.key, version) + } + } + + if (devDependencyUpdates) { + devDependencies.putAll(devDependencyUpdates) + } + + writeJSON file: "${packageFile}", json: packageContents, pretty: 4 archiveArtifacts artifacts: "${packageFile}" } From 03fddeff1708ede449fb60f434c53cdcbd6e828c Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 14:51:11 -0600 Subject: [PATCH 31/34] Try disabling at the container. --- Jenkinsfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ca6c25d6..01c1451f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,12 @@ pipeline { image: node:20 command: - cat - tty: true + tty: true + env: + - name: NPM_CONFIG_PROGRESS + value: "false" + - name: NPM_CONFIG_SPIN + value: "false" ''' } } From 8c7a084352710bf03ee2f29a685e801ec01809cd Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 15:23:27 -0600 Subject: [PATCH 32/34] Added test and publish stages. --- Jenkinsfile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 01c1451f..6da50c26 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -99,8 +99,6 @@ color=never } steps { script { - - def packageFiles = findFiles glob: '**/package.json' packageFiles.each { packageFile -> def packageContents = readJSON file: "${packageFile}" @@ -155,6 +153,22 @@ color=never } } } + + stage('test') { + steps { + container('node') { + sh 'npx swim-build test' + } + } + } + + stage('publish') { + steps { + container('node') { + sh 'npx swim-build publish' + } + } + } } } From ed9271fb7084fa400568595cafb7b114e3cd8d7e Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 15:26:29 -0600 Subject: [PATCH 33/34] Remove color config. --- Jenkinsfile | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6da50c26..f042c489 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,30 +15,12 @@ pipeline { image: node:20 command: - cat - tty: true - env: - - name: NPM_CONFIG_PROGRESS - value: "false" - - name: NPM_CONFIG_SPIN - value: "false" + tty: true ''' } } stages { - stage('configure-npm') { - steps { - container('node') { - script { - def npmrc = """ -progress=false -color=never -""" - writeFile file: '.npmrc', text: npmrc - } - } - } - } stage('read-version') { steps { script { From 95bd06c19d87842cf6445004f97d66325f16f56c Mon Sep 17 00:00:00 2001 From: Jeremy Custenborder Date: Thu, 9 Nov 2023 15:34:47 -0600 Subject: [PATCH 34/34] Enable ansicolor. --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index f042c489..8af89860 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,7 @@ pipeline { options { timeout(time: 1, unit: 'HOURS') + ansiColor('xterm') } agent { kubernetes {