Skip to content

Commit

Permalink
Parse Jenkinsfile as groovy and missing forkCount
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesbusy committed Dec 31, 2024
1 parent 714ed37 commit f7b2431
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/rewrite/rewrite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ recipeList:
- org.openrewrite.text.CreateTextFile:
relativeFileName: Jenkinsfile
overwriteExisting: true
fileContents: >
fileContents: |
/*
See the documentation for more options:
https://github.com/jenkins-infra/pipeline-library/
*/
buildPlugin(
forkCount: '1C', // run this number of tests in parallel for faster feedback. If the number terminates with a 'C', the value will be multiplied by the number of available CPU cores
useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests
configurations: [
[platform: 'linux', jdk: 21],
Expand Down
54 changes: 27 additions & 27 deletions src/test/java/org/openrewrite/jenkins/ModernizeJenkinsfileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.groovy.Assertions.groovy;
import static org.openrewrite.maven.Assertions.pomXml;
import static org.openrewrite.test.SourceSpecs.text;

class ModernizeJenkinsfileTest implements RewriteTest {

Expand Down Expand Up @@ -57,19 +57,19 @@ void shouldCreateJenkinsfile() {
</project>
"""),
//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")));
groovy(null, """
/*
See the documentation for more options:
https://github.com/jenkins-infra/pipeline-library/
*/
buildPlugin(
forkCount: '1C', // run this number of tests in parallel for faster feedback. If the number terminates with a 'C', the value will be multiplied by the number of available CPU cores
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
Expand Down Expand Up @@ -101,18 +101,18 @@ void shouldUpdateJenkinsfile() {
"""
),
//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],
])
""",
spec -> spec.noTrim().path("Jenkinsfile")));
groovy("buildPlugin()", """
/*
See the documentation for more options:
https://github.com/jenkins-infra/pipeline-library/
*/
buildPlugin(
forkCount: '1C', // run this number of tests in parallel for faster feedback. If the number terminates with a 'C', the value will be multiplied by the number of available CPU cores
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.noTrim().path("Jenkinsfile")));
}
}

0 comments on commit f7b2431

Please sign in to comment.