Skip to content

Commit

Permalink
Refresh plugin for January 2024
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin Delaye <jonesbusy@gmail.com>
  • Loading branch information
jonesbusy committed Jan 3, 2024
1 parent 68eb555 commit 4584db3
Show file tree
Hide file tree
Showing 30 changed files with 140 additions and 156 deletions.
38 changes: 0 additions & 38 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

10 changes: 0 additions & 10 deletions .github/ISSUE_TEMPLATE/custom.md

This file was deleted.

20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

7 changes: 5 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
interval: monthly
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
19 changes: 19 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Note: additional setup is required, see https://www.jenkins.io/redirect/continuous-delivery-of-plugins

name: cd
on:
workflow_dispatch:
check_run:
types:
- completed

permissions:
checks: read
contents: write

jobs:
maven-cd:
uses: jenkins-infra/github-reusable-workflows/.github/workflows/maven-cd.yml@v1
secrets:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.7</version>
</extension>
</extensions>
3 changes: 3 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
-Dchangelist.format=%d.v%s
11 changes: 10 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
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],
])
38 changes: 15 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.4</version>
<version>4.76</version>
<relativePath />
</parent>
<groupId>io.jenkins.plugins</groupId>
<artifactId>pipeline-as-yaml</artifactId>
<version>0.17-rc-SNAPSHOT</version>
<version>${changelist}</version>
<packaging>hpi</packaging>
<name>Pipeline As YAML (Incubated)</name>
<description>Enables defining Jenkins Pipelines in YAML Format</description>
Expand All @@ -21,10 +21,10 @@
</license>
</licenses>
<scm>
<connection>scm:git:ssh://github.com/jenkinsci/pipeline-as-yaml-plugin.git</connection>
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/pipeline-as-yaml-plugin.git</developerConnection>
<connection>scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
<url>/~https://github.com/jenkinsci/pipeline-as-yaml-plugin</url>
<tag>HEAD</tag>
<tag>${scmTag}</tag>
</scm>
<developers>
<developer>
Expand All @@ -34,17 +34,17 @@
</developer>
</developers>
<properties>
<java.level>8</java.level>
<jenkins.version>2.222.1</jenkins.version>
<changelist>999999-SNAPSHOT</changelist>
<jenkins.version>2.401.3</jenkins.version>
<hpi.compatibleSinceVersion>0.13-rc</hpi.compatibleSinceVersion>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.222.x</artifactId>
<version>11</version>
<artifactId>bom-2.401.x</artifactId>
<version>2675.v1515e14da_7a_6</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down Expand Up @@ -88,15 +88,9 @@
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
</dependency>
<!--TODO(oleg_nenashev): Ideally should come from BOM-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps-global-lib</artifactId>
<groupId>io.jenkins.plugins</groupId>
<artifactId>commons-lang3-api</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -105,22 +99,20 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>snakeyaml-api</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
<groupId>io.jenkins.plugins</groupId>
<artifactId>gson-api</artifactId>
</dependency>
<!-- TODO(oleg-nenashev): Replace explicit dependency once in BOM. /~https://github.com/jenkinsci/bom/pull/179 -->
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-model-definition</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public String toGroovy() {
StringBuffer groovyString = new StringBuffer()
.append(getLibraryOpen());
if (this.libraryList.size() == 1) {
groovyString.append(StringUtils.join(this.libraryList.toArray(), ","));
groovyString.append(StringUtils.joinArray(this.libraryList.toArray(new String[libraryList.size()]), ","));
} else {
groovyString.append("[");
groovyString.append(StringUtils.join(this.libraryList.toArray(), ","));
groovyString.append(StringUtils.joinArray(this.libraryList.toArray(new String[libraryList.size()]), ","));
groovyString.append("]");
}
groovyString.append(getLibraryClose());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Getter;
import lombok.Setter;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.representer.Representer;
Expand All @@ -22,10 +23,10 @@ public abstract class AbstractParser {
protected String yamlNodeName = "";
protected Yaml yaml;
public AbstractParser() {
Representer representer = new Representer();
Representer representer = new Representer(new DumperOptions());
representer.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN);
representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
this.yaml = new Yaml(new SafeConstructor(), representer);
this.yaml = new Yaml(new SafeConstructor(new LoaderOptions()), representer);
}

/**
Expand Down
17 changes: 9 additions & 8 deletions src/test/java/io/jenkins/plugins/pipeline/AgentParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Optional;

public class AgentParserTest {
Expand All @@ -20,7 +21,7 @@ public void setup() {

@Test
public void agentAnyTest() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentAny.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentAny.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand All @@ -31,7 +32,7 @@ public void agentAnyTest() throws IOException {

@Test
public void agentAnyShortTest() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentAnyShort.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentAnyShort.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand All @@ -43,7 +44,7 @@ public void agentAnyShortTest() throws IOException {

@Test
public void agentNoneTest() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentNone.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentNone.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand All @@ -54,7 +55,7 @@ public void agentNoneTest() throws IOException {

@Test
public void agentLabel() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentLabel.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentLabel.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand All @@ -68,7 +69,7 @@ public void agentLabel() throws IOException {

@Test
public void agentNode() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentNode.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentNode.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand All @@ -82,7 +83,7 @@ public void agentNode() throws IOException {

@Test
public void agentDocker() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentDocker.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentDocker.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand All @@ -94,7 +95,7 @@ public void agentDocker() throws IOException {

@Test
public void agentDockerFile() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentDockerfile.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentDockerfile.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand All @@ -106,7 +107,7 @@ public void agentDockerFile() throws IOException {

@Test
public void agentKubernetes() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentKubernetes.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/agent/agentKubernetes.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Optional;

public class EnvironmentParserTest {
Expand All @@ -35,7 +36,7 @@ public void setup() {

@Test
public void environmentSingle() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/environment/environmentSingle.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/environment/environmentSingle.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand All @@ -50,7 +51,7 @@ public void environmentSingle() throws IOException {

@Test
public void environmentMulti() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/environment/environmentMulti.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/environment/environmentMulti.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Optional;

public class LibraryParserTest {

@Test
public void scenario1() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/library/librarySingle.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/library/librarySingle.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand All @@ -28,7 +29,7 @@ public void scenario1() throws IOException {

@Test
public void scenario2() throws IOException {
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/library/libraryMulti.yml"));
String jenkinsFileContent = FileUtils.readFileToString(new File("src/test/resources/library/libraryMulti.yml"), StandardCharsets.UTF_8);
PipelineParser pipelineParser = new PipelineParser(jenkinsFileContent);
Optional<PipelineModel> pipelineModel = pipelineParser.parse();
Assert.assertTrue(pipelineModel.isPresent());
Expand Down
Loading

0 comments on commit 4584db3

Please sign in to comment.