Skip to content

Commit

Permalink
Merge pull request #51 from gounthar/jdk21
Browse files Browse the repository at this point in the history
  • Loading branch information
sghill authored Oct 11, 2023
2 parents 32fe11e + 875e43c commit 20f0573
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
13 changes: 9 additions & 4 deletions src/main/resources/META-INF/rewrite/rewrite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 34 additions & 19 deletions src/test/java/org/openrewrite/jenkins/ModernizeJenkinsfileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public void defaults(RecipeSpec spec) {

@Test
void shouldCreateJenkinsfile() {
rewriteRun(pomXml(
rewriteRun(
//language=xml
pomXml(
"""
<project>
<parent>
Expand All @@ -54,19 +56,28 @@ void shouldCreateJenkinsfile() {
</repositories>
</project>
"""),
text(null, """
buildPlugin(useContainerAgent: true, configurations: [
[ platform: 'linux', jdk: '11' ],
[ platform: 'windows', jdk: '11' ],
[ platform: 'linux', jdk: '17' ],
])""".stripIndent(),
//language=groovy
text(null,
"""
/*
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],
])
""",
spec -> spec.path("Jenkinsfile")));
}

@Test
@DocumentExample
void shouldUpdateJenkinsfile() {
rewriteRun(pomXml(
rewriteRun(
//language=xml
pomXml(
"""
<project>
<parent>
Expand All @@ -87,17 +98,21 @@ void shouldUpdateJenkinsfile() {
</repository>
</repositories>
</project>
"""),
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")));
}
}

0 comments on commit 20f0573

Please sign in to comment.