From 0156a36f47f4f4df92cb9910d2e5a3755ea04653 Mon Sep 17 00:00:00 2001 From: gounthar Date: Fri, 6 Oct 2023 18:21:57 +0200 Subject: [PATCH 1/3] chore(dependencies): Move to JDK21 The default archetype has changed: https://github.com/jenkinsci/archetypes/blob/master/common-files/Jenkinsfile --- src/main/resources/META-INF/rewrite/rewrite.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/resources/META-INF/rewrite/rewrite.yml b/src/main/resources/META-INF/rewrite/rewrite.yml index d502465..d1389cf 100644 --- a/src/main/resources/META-INF/rewrite/rewrite.yml +++ b/src/main/resources/META-INF/rewrite/rewrite.yml @@ -58,10 +58,15 @@ recipeList: relativeFileName: Jenkinsfile overwriteExisting: true fileContents: > - buildPlugin(useContainerAgent: true, configurations: [ - [ platform: 'linux', jdk: '11' ], - [ platform: 'windows', jdk: '11' ], - [ platform: 'linux', jdk: '17' ], + /* + See the documentation for more options: + https://github.com/jenkins-infra/pipeline-library/ + */ + buildPlugin( + useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests + configurations: [ + [platform: 'linux', jdk: 21], + [platform: 'windows', jdk: 17], ]) --- type: specs.openrewrite.org/v1beta/recipe From 46bf237ff54ef7dc1259d16fbb3ec86d41f53e48 Mon Sep 17 00:00:00 2001 From: gounthar Date: Fri, 6 Oct 2023 22:17:49 +0200 Subject: [PATCH 2/3] chore(dependencies): Move to JDK21 The default archetype has changed: https://github.com/jenkinsci/archetypes/blob/master/common-files/Jenkinsfile --- .../jenkins/ModernizeJenkinsfileTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/openrewrite/jenkins/ModernizeJenkinsfileTest.java b/src/test/java/org/openrewrite/jenkins/ModernizeJenkinsfileTest.java index 5ccc9dc..e063b54 100644 --- a/src/test/java/org/openrewrite/jenkins/ModernizeJenkinsfileTest.java +++ b/src/test/java/org/openrewrite/jenkins/ModernizeJenkinsfileTest.java @@ -55,10 +55,15 @@ void shouldCreateJenkinsfile() { """), text(null, """ - buildPlugin(useContainerAgent: true, configurations: [ - [ platform: 'linux', jdk: '11' ], - [ platform: 'windows', jdk: '11' ], - [ platform: 'linux', jdk: '17' ], + /* + See the documentation for more options: + https://github.com/jenkins-infra/pipeline-library/ + */ + buildPlugin( + useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests + configurations: [ + [platform: 'linux', jdk: 21], + [platform: 'windows', jdk: 17], ])""".stripIndent(), spec -> spec.path("Jenkinsfile"))); } From 875e43c067ace16955f15c6a5691e46eb2b05623 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Wed, 11 Oct 2023 13:39:01 +0100 Subject: [PATCH 3/3] Fix asserted outcome & apply formatter --- .../jenkins/ModernizeJenkinsfileTest.java | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/test/java/org/openrewrite/jenkins/ModernizeJenkinsfileTest.java b/src/test/java/org/openrewrite/jenkins/ModernizeJenkinsfileTest.java index e063b54..d73af0e 100644 --- a/src/test/java/org/openrewrite/jenkins/ModernizeJenkinsfileTest.java +++ b/src/test/java/org/openrewrite/jenkins/ModernizeJenkinsfileTest.java @@ -32,7 +32,9 @@ public void defaults(RecipeSpec spec) { @Test void shouldCreateJenkinsfile() { - rewriteRun(pomXml( + rewriteRun( + //language=xml + pomXml( """ @@ -54,24 +56,28 @@ void shouldCreateJenkinsfile() { """), - text(null, """ + //language=groovy + text(null, + """ /* See the documentation for more options: https://github.com/jenkins-infra/pipeline-library/ - */ - buildPlugin( + */ buildPlugin( useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests configurations: [ [platform: 'linux', jdk: 21], [platform: 'windows', jdk: 17], - ])""".stripIndent(), + ]) + """, spec -> spec.path("Jenkinsfile"))); } @Test @DocumentExample void shouldUpdateJenkinsfile() { - rewriteRun(pomXml( + rewriteRun( + //language=xml + pomXml( """ @@ -92,17 +98,21 @@ void shouldUpdateJenkinsfile() { - """), - text(""" - buildPlugin() - """.stripIndent(), """ - buildPlugin(useContainerAgent: true, configurations: [ - [ platform: 'linux', jdk: '11' ], - [ platform: 'windows', jdk: '11' ], - [ platform: 'linux', jdk: '17' ], + """ + ), + //language=groovy + text("buildPlugin()", + """ + /* + See the documentation for more options: + https://github.com/jenkins-infra/pipeline-library/ + */ buildPlugin( + useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests + configurations: [ + [platform: 'linux', jdk: 21], + [platform: 'windows', jdk: 17], ]) - - """.stripIndent(), - spec -> spec.path("Jenkinsfile"))); + """, + spec -> spec.noTrim().path("Jenkinsfile"))); } }