From 219e2686d43901dd19dc085b4814cff3980bcfd4 Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Thu, 6 Jul 2023 13:53:50 +0200 Subject: [PATCH 1/5] Flatten repositories from JEP-229 plugins This workarounds https://github.com/mojohaus/flatten-maven-plugin/issues/362 and strips from deployed pom for plugins using JEP-229 --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index 2e2da9d649..f8afca29e7 100644 --- a/pom.xml +++ b/pom.xml @@ -1338,6 +1338,9 @@ oss ${project.build.directory} ${project.artifactId}-${project.version}.pom + + flatten + From 7835622cc727c16874a68bf4353f3d18ca109d22 Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Thu, 6 Jul 2023 14:27:52 +0200 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: Jesse Glick --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index f8afca29e7..126382f4c5 100644 --- a/pom.xml +++ b/pom.xml @@ -1338,6 +1338,7 @@ oss ${project.build.directory} ${project.artifactId}-${project.version}.pom + flatten From b5daedba5d62b130b1c25d6b2b7783fc9502a8fb Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Thu, 6 Jul 2023 14:54:01 +0200 Subject: [PATCH 3/5] Add an IT --- src/it/cd-plugin/.mvn/extensions.xml | 7 +++ src/it/cd-plugin/.mvn/maven.config | 3 ++ src/it/cd-plugin/invoker.properties | 2 + src/it/cd-plugin/pom.xml | 47 +++++++++++++++++++ src/it/cd-plugin/postbuild.groovy | 23 +++++++++ .../src/main/java/test/SampleRootAction.java | 28 +++++++++++ .../cd-plugin/src/main/resources/index.jelly | 2 + .../test/java/test/SampleRootActionTest.java | 25 ++++++++++ .../src/test/resources/test/expected.txt | 1 + 9 files changed, 138 insertions(+) create mode 100644 src/it/cd-plugin/.mvn/extensions.xml create mode 100644 src/it/cd-plugin/.mvn/maven.config create mode 100644 src/it/cd-plugin/invoker.properties create mode 100644 src/it/cd-plugin/pom.xml create mode 100644 src/it/cd-plugin/postbuild.groovy create mode 100644 src/it/cd-plugin/src/main/java/test/SampleRootAction.java create mode 100644 src/it/cd-plugin/src/main/resources/index.jelly create mode 100644 src/it/cd-plugin/src/test/java/test/SampleRootActionTest.java create mode 100644 src/it/cd-plugin/src/test/resources/test/expected.txt diff --git a/src/it/cd-plugin/.mvn/extensions.xml b/src/it/cd-plugin/.mvn/extensions.xml new file mode 100644 index 0000000000..90787cbb2d --- /dev/null +++ b/src/it/cd-plugin/.mvn/extensions.xml @@ -0,0 +1,7 @@ + + + io.jenkins.tools.incrementals + git-changelist-maven-extension + 1.6 + + diff --git a/src/it/cd-plugin/.mvn/maven.config b/src/it/cd-plugin/.mvn/maven.config new file mode 100644 index 0000000000..f7daf60d07 --- /dev/null +++ b/src/it/cd-plugin/.mvn/maven.config @@ -0,0 +1,3 @@ +-Pconsume-incrementals +-Pmight-produce-incrementals +-Dchangelist.format=%d.v%s diff --git a/src/it/cd-plugin/invoker.properties b/src/it/cd-plugin/invoker.properties new file mode 100644 index 0000000000..42e9017061 --- /dev/null +++ b/src/it/cd-plugin/invoker.properties @@ -0,0 +1,2 @@ +# Same options as in https://github.com/jenkins-infra/jenkins-maven-cd-action/blob/master/run.sh +invoker.goals=-Dstyle.color=always -Dset.changelist -Dchangelist=1234.deadbeef5678 -ntp -P-consume-incrementals -Pquick-build clean install diff --git a/src/it/cd-plugin/pom.xml b/src/it/cd-plugin/pom.xml new file mode 100644 index 0000000000..ab64c77d1a --- /dev/null +++ b/src/it/cd-plugin/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + org.jenkins-ci.plugins + plugin + @project.version@ + + + org.jenkins-ci.plugins.its + cd-plugin + ${changelist} + hpi + CD plugin + CD description + + 999999-SNAPSHOT + false + + + + + org.jenkins-ci.plugins + structs + 1.5 + + + + + + org.jenkins-ci.plugins + structs + + + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + + diff --git a/src/it/cd-plugin/postbuild.groovy b/src/it/cd-plugin/postbuild.groovy new file mode 100644 index 0000000000..0fce501e7e --- /dev/null +++ b/src/it/cd-plugin/postbuild.groovy @@ -0,0 +1,23 @@ +assert new File(basedir, 'target/cd-plugin.hpi').file +assert new File(basedir, 'target/cd-plugin.jar').file + +File installed = new File(basedir, '../../local-repo/org/jenkins-ci/plugins/its/cd-plugin/1234.deadbeef5678/') +assert new File(installed, 'cd-plugin-1234.deadbeef5678.hpi').file + +def targetPom = new File(basedir, 'target/cd-plugin-1234.deadbeef5678.pom') +assert targetPom.file + +def installedPom = new File(installed, 'cd-plugin-1234.deadbeef5678.pom') +assert installedPom.file + +assert installedPom.text.contains("") +assert installedPom.text.contains("") +assert installedPom.text.contains("") +assert installedPom.text.contains("") +assert installedPom.text.contains("") +assert !installedPom.text.contains("") +assert !installedPom.text.contains("") +assert !installedPom.text.contains("") +assert !installedPom.text.contains("") + +return true diff --git a/src/it/cd-plugin/src/main/java/test/SampleRootAction.java b/src/it/cd-plugin/src/main/java/test/SampleRootAction.java new file mode 100644 index 0000000000..66611bacbb --- /dev/null +++ b/src/it/cd-plugin/src/main/java/test/SampleRootAction.java @@ -0,0 +1,28 @@ +package test; + +import hudson.Extension; +import hudson.model.RootAction; +import org.kohsuke.stapler.HttpResponse; +import org.kohsuke.stapler.HttpResponses; + +@Extension +public class SampleRootAction implements RootAction { + @Override + public String getUrlName() { + return "sample"; + } + + @Override + public String getIconFileName() { + return null; + } + + @Override + public String getDisplayName() { + return null; + } + + public HttpResponse doIndex() { + return HttpResponses.plainText("sample served"); + } +} diff --git a/src/it/cd-plugin/src/main/resources/index.jelly b/src/it/cd-plugin/src/main/resources/index.jelly new file mode 100644 index 0000000000..2f655e510a --- /dev/null +++ b/src/it/cd-plugin/src/main/resources/index.jelly @@ -0,0 +1,2 @@ + +
diff --git a/src/it/cd-plugin/src/test/java/test/SampleRootActionTest.java b/src/it/cd-plugin/src/test/java/test/SampleRootActionTest.java new file mode 100644 index 0000000000..4e6ccea880 --- /dev/null +++ b/src/it/cd-plugin/src/test/java/test/SampleRootActionTest.java @@ -0,0 +1,25 @@ +package test; + +import static org.junit.Assert.*; + +import org.apache.commons.io.IOUtils; +import org.junit.Rule; +import org.junit.Test; +import org.jvnet.hudson.test.JenkinsRule; + +public class SampleRootActionTest { + + @Rule + public JenkinsRule r = new JenkinsRule(); + + @Test + public void smokes() throws Exception { + assertEquals( + IOUtils.toString(SampleRootActionTest.class.getResource("expected.txt")), + r.createWebClient() + .goTo("sample", "text/plain") + .getWebResponse() + .getContentAsString() + .trim()); + } +} diff --git a/src/it/cd-plugin/src/test/resources/test/expected.txt b/src/it/cd-plugin/src/test/resources/test/expected.txt new file mode 100644 index 0000000000..f18734ec4a --- /dev/null +++ b/src/it/cd-plugin/src/test/resources/test/expected.txt @@ -0,0 +1 @@ +sample served \ No newline at end of file From 532cddae3c4e6a4446738aa3e5aedb25e08c3e01 Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Thu, 6 Jul 2023 16:46:19 +0200 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: Jesse Glick --- src/it/cd-plugin/invoker.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/it/cd-plugin/invoker.properties b/src/it/cd-plugin/invoker.properties index 42e9017061..c459b1104e 100644 --- a/src/it/cd-plugin/invoker.properties +++ b/src/it/cd-plugin/invoker.properties @@ -1,2 +1,2 @@ -# Same options as in https://github.com/jenkins-infra/jenkins-maven-cd-action/blob/master/run.sh +# Same options as in https://github.com/jenkins-infra/jenkins-maven-cd-action/blob/master/run.sh (but hard-coding a sample changelist) invoker.goals=-Dstyle.color=always -Dset.changelist -Dchangelist=1234.deadbeef5678 -ntp -P-consume-incrementals -Pquick-build clean install From 2e44a9931fdae3b65f56ecedfd5044ff4ff74f38 Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Thu, 6 Jul 2023 16:47:35 +0200 Subject: [PATCH 5/5] Remove unused resources --- .../src/main/java/test/SampleRootAction.java | 28 ------------------- .../test/java/test/SampleRootActionTest.java | 25 ----------------- .../src/test/resources/test/expected.txt | 1 - 3 files changed, 54 deletions(-) delete mode 100644 src/it/cd-plugin/src/main/java/test/SampleRootAction.java delete mode 100644 src/it/cd-plugin/src/test/java/test/SampleRootActionTest.java delete mode 100644 src/it/cd-plugin/src/test/resources/test/expected.txt diff --git a/src/it/cd-plugin/src/main/java/test/SampleRootAction.java b/src/it/cd-plugin/src/main/java/test/SampleRootAction.java deleted file mode 100644 index 66611bacbb..0000000000 --- a/src/it/cd-plugin/src/main/java/test/SampleRootAction.java +++ /dev/null @@ -1,28 +0,0 @@ -package test; - -import hudson.Extension; -import hudson.model.RootAction; -import org.kohsuke.stapler.HttpResponse; -import org.kohsuke.stapler.HttpResponses; - -@Extension -public class SampleRootAction implements RootAction { - @Override - public String getUrlName() { - return "sample"; - } - - @Override - public String getIconFileName() { - return null; - } - - @Override - public String getDisplayName() { - return null; - } - - public HttpResponse doIndex() { - return HttpResponses.plainText("sample served"); - } -} diff --git a/src/it/cd-plugin/src/test/java/test/SampleRootActionTest.java b/src/it/cd-plugin/src/test/java/test/SampleRootActionTest.java deleted file mode 100644 index 4e6ccea880..0000000000 --- a/src/it/cd-plugin/src/test/java/test/SampleRootActionTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package test; - -import static org.junit.Assert.*; - -import org.apache.commons.io.IOUtils; -import org.junit.Rule; -import org.junit.Test; -import org.jvnet.hudson.test.JenkinsRule; - -public class SampleRootActionTest { - - @Rule - public JenkinsRule r = new JenkinsRule(); - - @Test - public void smokes() throws Exception { - assertEquals( - IOUtils.toString(SampleRootActionTest.class.getResource("expected.txt")), - r.createWebClient() - .goTo("sample", "text/plain") - .getWebResponse() - .getContentAsString() - .trim()); - } -} diff --git a/src/it/cd-plugin/src/test/resources/test/expected.txt b/src/it/cd-plugin/src/test/resources/test/expected.txt deleted file mode 100644 index f18734ec4a..0000000000 --- a/src/it/cd-plugin/src/test/resources/test/expected.txt +++ /dev/null @@ -1 +0,0 @@ -sample served \ No newline at end of file