Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Use pom.xml to describe the packaged plug-in #75

Open
seanly opened this issue Jan 7, 2022 · 2 comments
Open

Proposal: Use pom.xml to describe the packaged plug-in #75

seanly opened this issue Jan 7, 2022 · 2 comments

Comments

@seanly
Copy link

seanly commented Jan 7, 2022

Currently, there are a problems with describing dependencies on plug-ins that need to be packaged in the plugins field of the formula file:

  • After upgrading Jenkins version, all relevant plug-ins need to be re-confirmed one by one, otherwise the following errors will occur
    image

Proposal

Write the information about the plug-in to be packaged in the pom.xml file and reference it in the formula.yaml file as follows:

# formula.yaml
bundle:
  groupId: io.github.ks-jenkins
  artifactId: ks-jenkins
  description: Jenkins formula for Kubesphere
  vendor: Kubesphere Community
buildSettings:
  docker:
    base: jenkins/jenkins:2.319.1
    tag: {{.tag}}
    output: {{.output}}
    platform: {{.platform}}
    buildx: true
    build: true
  pom: pom.xml
  pomIgnoreRoot: true
  pomIncludeWar: true
war:
  groupId: org.jenkins-ci.main
  artifactId: jenkins-war
  source:
    version: 2.319.1
systemProperties:
  hudson.security.csrf.DefaultCrumbIssuer.EXCLUDE_SESSION_ID: "true"
  jenkins.install.runSetupWizard: "false"
groovyHooks:
  - type: "init"
    id: "bundle-plugins"
    source:
      dir: remove-bundle-plugins.groovy

With the help of the plugin version relationships already sorted out by the community, only the bom needs to be updated when upgrading the Jenkins version

<!-- pom.xml -->
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.jenkins.tools.bom</groupId>
        <artifactId>bom-2.319.x</artifactId>
        <version>1090.v0a_33df40457a_</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>

Add plug-in dependencies like this

  <dependencies>
    <!-- jenkins plugins -->
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>token-macro</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>cloudbees-folder</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>credentials-binding</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins.workflow</groupId>
      <artifactId>workflow-step-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>structs</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins.workflow</groupId>
      <artifactId>workflow-cps</artifactId>
    </dependency>
    <dependency>
      <groupId>io.jenkins</groupId>
      <artifactId>configuration-as-code</artifactId>
      <version>1.55</version>
    </dependency>
    <dependency>
      <groupId>io.jenkins.blueocean</groupId>
      <artifactId>blueocean</artifactId>
      <version>1.25.2</version>
    </dependency>
  </dependencies>

This also has the benefit of upgrading some of the dependent libraries

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.7</version>
      </dependency>
      <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>4.0.1</version>
      </dependency>
      <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-utils</artifactId>
        <version>3.3.0</version>
      </dependency>
      <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java</artifactId>
        <version>3.11.4</version>
      </dependency>
      <dependency>
        <groupId>org.jenkins-ci</groupId>
        <artifactId>symbol-annotation</artifactId>
        <version>1.22</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

Methods validation

After running the two packaged images, export plugins.txt and the comparison results are consistent

# method A
make build

docker run --rm -it -p 8080:8080 kubespheredev/ks-jenkins:test

curl -sSL "http://localhost:8080/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins" | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1 \2\n/g'|sed 's/ /:/' > plugins-a.txt

# method B

# export plugins-b.txt

# diff
vimdiff plugins-a.txt plugins-b.txt

diff result:
image

@JohnNiang
Copy link
Member

I'm wondering if we can run the ks-jenkins in GitHub workflow exactly after every build of ks-jenkins. This run may detect dependency problems.

@LinuxSuRen
Copy link
Member

I'm wondering if we can run the ks-jenkins in GitHub workflow exactly after every build of ks-jenkins. This run may detect dependency problems.

This is a good idea. But it is not conflicted with #76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants