diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..b01ad2f0 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @jenkinsci/build-pipeline-plugin-developers diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..978c2925 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file +--- +version: 2 +updates: + - package-ecosystem: "maven" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..f3eb14e7 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,4 @@ +# https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.adoc +--- +_extends: .github +tag-template: build-pipeline-plugin-$NEXT_MINOR_VERSION diff --git a/.github/workflows/jenkins-security-scan.yml b/.github/workflows/jenkins-security-scan.yml new file mode 100644 index 00000000..ecda979c --- /dev/null +++ b/.github/workflows/jenkins-security-scan.yml @@ -0,0 +1,24 @@ +# Jenkins Security Scan +# For more information, see: https://www.jenkins.io/doc/developer/security/scan/ +--- +name: Jenkins Security Scan + +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] + workflow_dispatch: + +permissions: + security-events: write + contents: read + actions: read + +jobs: + security-scan: + uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v2 + with: + java-cache: 'maven' # Optionally enable use of a build dependency cache. Specify 'maven' or 'gradle' as appropriate. + # java-version: 21 # Optionally specify what version of Java to set up for the build, or remove to use a recent default. diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 00000000..4fc3d2cf --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,16 @@ +# Automates creation of Release Drafts using Release Drafter +# More Info: https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.adoc +--- +on: + push: + branches: + - master + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 0c0b1193..08343646 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,15 @@ -.classpath -.project -.settings - -*.iml - -**/*.iml - target -work -.checkstyle -checkstyle-cachefile +# mvn hpi:run +work -# IntelliJ -.idea/ +# IntelliJ IDEA project files *.iml -*.ipr *.iws +*.ipr +.idea +# Eclipse project files +.settings +.classpath +.project diff --git a/.hgignore b/.hgignore deleted file mode 100644 index 8152ee12..00000000 --- a/.hgignore +++ /dev/null @@ -1,12 +0,0 @@ -^target$ -^work$ -^bin -^.classpath -^.project -^.settings -^.checkstyle -^.DS_Store -^.idea$ -build-pipeline-plugin.iml -build-pipeline-plugin.ipr -build-pipeline-plugin.iws \ No newline at end of file diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml new file mode 100644 index 00000000..4e0774d5 --- /dev/null +++ b/.mvn/extensions.xml @@ -0,0 +1,7 @@ + + + io.jenkins.tools.incrementals + git-changelist-maven-extension + 1.8 + + diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 00000000..2a0299c4 --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1,2 @@ +-Pconsume-incrementals +-Pmight-produce-incrementals diff --git a/Jenkinsfile b/Jenkinsfile index c9748bb4..ef559ba3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,7 @@ #!/usr/bin/env groovy /* `buildPlugin` step provided by: https://github.com/jenkins-infra/pipeline-library */ -buildPlugin(configurations: [ - [ platform: 'linux', jdk: '11' ], - [ platform: 'windows', jdk: '11' ], - // Compilation fails on Java 17 - // [ platform: 'linux', jdk: '17' ], +buildPlugin(useContainerAgent: true, configurations: [ + [platform: 'linux', jdk: 21], + [platform: 'windows', jdk: 17] ]) diff --git a/pom.xml b/pom.xml index 291f2de6..51d3ad77 100644 --- a/pom.xml +++ b/pom.xml @@ -1,37 +1,39 @@ + 4.0.0 org.jenkins-ci.plugins plugin - 4.74 + 4.88 build-pipeline-plugin - 2.0.3-SNAPSHOT + ${revision}${changelist} hpi Build Pipeline Plugin This plugin provides build pipeline functionality to Hudson and Jenkins. This allows a chain of jobs to be visualised in a new view. Manual jobs in the pipeline can be triggered by a user with the appropriate permissions manually confirming. - https://github.com/jenkinsci/build-pipeline-plugin + https://github.com/jenkinsci/${project.artifactId} MIT License - http://www.opensource.org/licenses/mit-license.php + https://opensource.org/license/mit/ - scm:git:https://github.com/jenkinsci/${project.artifactId}.git - scm:git:git@github.com:jenkinsci/${project.artifactId}.git - https://github.com/jenkinsci/build-pipeline-plugin - HEAD + scm:git:https://github.com/${gitHubRepo}.git + scm:git:git@github.com:${gitHubRepo}.git + https://github.com/${gitHubRepo} + ${scmTag} + 2.0.3 + -SNAPSHOT + 2.414.3 + jenkinsci/${project.artifactId} 50 - checkstyle_rules.xml - UTF-8 - 1.8.6 - 4.1.4 - **/functionaltest/*.java - 2.361.4 + 4.25.0 + + High @@ -50,8 +52,8 @@ io.jenkins.tools.bom - bom-2.361.x - 2102.v854b_fec19c92 + bom-2.414.x + 2928.ved44ea_84e034 pom import @@ -66,7 +68,7 @@ org.spockframework spock-core - 1.0-groovy-2.4 + 1.3-groovy-2.4 test @@ -83,14 +85,14 @@ org.jenkins-ci.plugins jquery - 1.7.2-1 + 1.12.4-1 cglib cglib-nodep - 2.2 + 3.3.0 test @@ -108,12 +110,10 @@ org.jenkins-ci.plugins parameterized-trigger - 2.45 org.jenkins-ci.plugins matrix-auth - 3.1.5 @@ -152,12 +152,6 @@ - - org.seleniumhq.selenium - selenium-ie-driver - ${selenium.version} - test - org.seleniumhq.selenium selenium-support @@ -170,6 +164,12 @@ + + io.github.bonigarcia + webdrivermanager + 5.9.2 + test + commons-beanutils @@ -187,36 +187,15 @@ - org.codehaus.gmaven - gmaven-plugin - 1.4 - - - 1.8 - - - - org.codehaus.gmaven.runtime - gmaven-runtime-1.8 - 1.4 - - - org.codehaus.groovy - groovy-all - - - - - org.codehaus.groovy - groovy-all - ${groovy.version} - - + org.codehaus.gmavenplus + gmavenplus-plugin + addSources generateStubs compile + removeStubs @@ -224,10 +203,10 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.3.0 + 3.3.1 - ${checkstyle.rules.file} - checkstyle_suppressions.xml + ${project.basedir}/checkstyle_rules.xml + ${project.basedir}/checkstyle_suppressions.xml true warning basedir=${basedir} @@ -242,38 +221,6 @@ - - org.apache.maven.plugins - maven-release-plugin - 2.5.2 - - web-tests - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${exclude.tests} - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - attach-javadocs - - jar - - - - - false - - @@ -326,15 +273,6 @@ - - - web-tests - - none - - - - repo.jenkins-ci.org @@ -359,4 +297,32 @@ + + + windows-ci + + + Windows + + + env.CI + + + + + + maven-surefire-plugin + + + + au.com.centrumsystems.hudson.plugin.buildpipeline.functionaltest.BuildPipelineViewTest + au.com.centrumsystems.hudson.plugin.buildpipeline.functionaltest.BuildSecurityTest + au.com.centrumsystems.hudson.plugin.buildpipeline.functionaltest.ParameterPassingTest + + + + + + + diff --git a/src/test/java/au/com/centrumsystems/hudson/plugin/buildpipeline/testsupport/LoginLogoutPage.java b/src/test/java/au/com/centrumsystems/hudson/plugin/buildpipeline/testsupport/LoginLogoutPage.java index f043dcb1..bdb0a8bd 100644 --- a/src/test/java/au/com/centrumsystems/hudson/plugin/buildpipeline/testsupport/LoginLogoutPage.java +++ b/src/test/java/au/com/centrumsystems/hudson/plugin/buildpipeline/testsupport/LoginLogoutPage.java @@ -24,7 +24,7 @@ public void login(String username) { usernameField().sendKeys(username); passwordField().sendKeys(username); - passwordField().submit(); + submitButton().click(); } private WebElement usernameField() { @@ -35,6 +35,10 @@ private WebElement passwordField() { return waitForElement(By.name("j_password"), driver); } + private WebElement submitButton() { + return waitForElement(By.name("Submit"), driver); + } + public void logout() { driver.get(baseUrl + "logout"); } diff --git a/src/test/java/au/com/centrumsystems/hudson/plugin/buildpipeline/testsupport/PipelineWebDriverTestBase.java b/src/test/java/au/com/centrumsystems/hudson/plugin/buildpipeline/testsupport/PipelineWebDriverTestBase.java index 4bcc392e..4dc953c2 100644 --- a/src/test/java/au/com/centrumsystems/hudson/plugin/buildpipeline/testsupport/PipelineWebDriverTestBase.java +++ b/src/test/java/au/com/centrumsystems/hudson/plugin/buildpipeline/testsupport/PipelineWebDriverTestBase.java @@ -1,15 +1,23 @@ package au.com.centrumsystems.hudson.plugin.buildpipeline.testsupport; +import io.github.bonigarcia.wdm.WebDriverManager; import au.com.centrumsystems.hudson.plugin.buildpipeline.BuildPipelineView; import au.com.centrumsystems.hudson.plugin.buildpipeline.DownstreamProjectGridBuilder; +import au.com.centrumsystems.hudson.plugin.buildpipeline.extension.SimpleColumnHeader; +import au.com.centrumsystems.hudson.plugin.buildpipeline.extension.SimpleRowHeader; +import au.com.centrumsystems.hudson.plugin.buildpipeline.extension.StandardBuildCard; import hudson.model.FreeStyleProject; +import org.apache.commons.lang.StringUtils; import org.junit.After; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Rule; import org.jvnet.hudson.test.FailureBuilder; import org.jvnet.hudson.test.JenkinsRule; +import org.openqa.selenium.NoSuchSessionException; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; public class PipelineWebDriverTestBase { @@ -27,6 +35,26 @@ public class PipelineWebDriverTestBase { protected PipelinePage pipelinePage; protected WebDriver webDriver; + protected static boolean isCi() { + return StringUtils.isNotBlank(System.getenv("CI")); + } + + @BeforeClass + public static void setUpClass() { + if (isCi()) { + // The browserVersion needs to match what is provided by the Jenkins Infrastructure + // If you see an exception like this: + // + // org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: This version of ChromeDriver only supports Chrome version 114 + // Current browser version is 112.0.5615.49 with binary path /usr/bin/chromium-browser + // + // Then that means you need to update the version here to match the current browser version. + WebDriverManager.chromedriver().browserVersion("112").setup(); + } else { + WebDriverManager.chromedriver().setup(); + } + } + @Before public void initSharedComponents() throws Exception { realm = jr.createDummySecurityRealm(); @@ -34,10 +62,14 @@ public void initSharedComponents() throws Exception { initialJob = jr.createFreeStyleProject(INITIAL_JOB); - pipelineView = new BuildPipelineView("pipeline", "Pipeline", new DownstreamProjectGridBuilder(INITIAL_JOB), "5", false, true, false, false, false, 1, null, null, null, null, null); + pipelineView = new BuildPipelineView("pipeline", "Pipeline", new DownstreamProjectGridBuilder(INITIAL_JOB), "5", false, true, false, false, false, 1, null, null, new SimpleColumnHeader(), new SimpleRowHeader(), new StandardBuildCard()); jr.jenkins.addView(pipelineView); - webDriver = new FirefoxDriver(); + if (isCi()) { + webDriver = new ChromeDriver(new ChromeOptions().addArguments("--headless", "--disable-dev-shm-usage", "--no-sandbox")); + } else { + webDriver = new ChromeDriver(new ChromeOptions()); + } loginLogoutPage = new LoginLogoutPage(webDriver, jr.getURL()); pipelinePage = new PipelinePage(webDriver, pipelineView.getViewName(), jr.getURL()); } @@ -45,7 +77,11 @@ public void initSharedComponents() throws Exception { @After public void cleanUpWebDriver() { webDriver.close(); - webDriver.quit(); + try { + webDriver.quit(); + } catch (NoSuchSessionException e) { + // Ignore + } } protected FreeStyleProject createFailingJob(String name) throws Exception{