Skip to content
Fred G edited this page Nov 21, 2024 · 12 revisions

Jenkins logo

Jenkins is a continuous integration (CI) server. It is in use on Eclipse servers for Eclipse projects as part of the Common Build Infrastructure (CBI). This page is about the hosted service at Eclipse.org. For more information on the project itself, or to download Jenkins, please see the Jenkins project page.

Table of Contents

General Information

Jenkins instances are maintained by the Eclipse Webmasters/Release Engineers.

Asking for Help

Requesting a JIPP instance for CBI

Please file a HelpDesk ticket to request your project's own instance. Please ensure your project lead can +1 the request.

FAQ

How can SonarCloud be integrated into a Jiro JIPP?

Integrating SonarCloud into a project's CI builds is quite easy. Please open a Bugzilla issue for this and the releng/webmaster team will help you set this up.

We're setting this up with the webmaster's SonarCloud.io account, so there is no need to provide a SonarCloud token. To avoid leaking the token in the console log, we store it as secret text (Jenkins credentials).

We will configure the SonarQube Jenkins plugin to use SonarCloud to achieve a slightly better integration with Jenkins. For example, a link to SonarCloud will show up in the left menu of a job page.

Freestyle job

For a freestyle job configuration two things need to be done:

  1. Under "Build environment" enable "Use secret text(s) or file(s)", add "Secret text", name the variable "SONARCLOUD_TOKEN" and select the right credential (e.g. "Sonarcloud token").
  2. either a shell build step or a Maven build step can be used to run the sonar goal with the right parameters:
    mvn clean verify sonar:sonar -Dsonar.projectKey=<project-name> -Dsonar.organization=<organization> -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.login=${SONARCLOUD_TOKEN}

Pipeline job

For a pipeline job the following needs to be added:

withCredentials([string(credentialsId: 'sonarcloud-token', variable: 'SONARCLOUD_TOKEN')]) {
    withSonarQubeEnv('SonarCloud.io') {
        mvn clean verify sonar:sonar -Dsonar.projectKey=<project-name> -Dsonar.organization=<organization> -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.login=${SONARCLOUD_TOKEN}
    }
}

Please note: <project-name></project-name> and <organization></organization> should be replaced with the corresponding project name and organization.

Can projects get admin access on their Jiro JIPP?

In general, we want to avoid handing out admin rights in the future. At the same time, - in the spirit of configuration as code - we are planning to allow projects to submit pull requests to our Jiro repo and change the configuration of their CI instance. E.g. adding plugins, etc. This will allow better tracking of configuration changes and rollback in case of issues.

We understand that some projects heavily rely on their admin permissions. We will make sure to find an amicable solution in those cases.

How can a new plugin be added to a Jiro JIPP?

The preferred way is to open a pull request in the Jiro GitHub repo. For example, to add a new plugin to the CBI instance, one would need to edit https://github.com/eclipse-cbi/jiro/blob/master/instances/technology.cbi/config.jsonnet and add the ID of the plugin to the plugins+ section. If the jenkins+/plugins+ section does not exist yet, it needs to be added as well.

Example:

&#123;
  project+&#58; &#123;
    fullName&#58; &quot;technology.cbi&quot;,
    displayName&#58; &quot;Eclipse CBI&quot;,
  &#125;,
  jenkins+&#58; &#123;
    plugins+&#58; &#91;
      &quot;jacoco&quot;,
    &#93;,
  &#125;
&#125;

Only additional plugins that are not listed in https://wiki.eclipse.org/Jenkins#Default_plugins_-_Jiro_.28ci-staging.eclipse.org.2Fxxx_and_ci.eclipse.org.2Fxxx.29 need to be added to the config.jsonnet file.

The ID of a Jenkins plugin can be found here: https://plugins.jenkins.io/

If this sounds to complicated, you can also open a bug on Bugzilla.

How to build my project's website with Jenkins?

The preferred static website generator for build Eclipse project websites is Hugo. You should first put your Hugo sources in a dedicated Git repository, either at GitHub if your source code is already hosted at GitHub or at git.eclipse.org. If you don't have such a repository already, feel free to open a request, the Eclipse IT team will create one for you.

Note that each and every Eclipse project automatically gets a Git repository with git.eclipse.org/www.eclipse.org/&amp;lt&#59;project_name&amp;gt&#59; (see this repository index for complete list). This is not where you want to push your Hugo sources. This repository contains the webpages that are automatically and regularly pulled and published on the www.eclipse.org HTTP server. All the content from the master branch will eventually be available at the URL https://www.eclipse.org/<project_name/>.

Once your Hugo sources are in the proper repository, create a file named Jenkinsfile at the root of the repository with the following content (don't forget to specify the proper value for PROJECT_NAME and PROJECT_BOT_NAME environment variable):

  environment &#123;
    PROJECT_NAME &#61; &quot;&amp;lt&#59;project_name&amp;gt&#59;&quot; // must be all lowercase.
    PROJECT_BOT_NAME &#61; &quot;&amp;lt&#59;Project_name&amp;gt&#59; Bot&quot; // Capitalize the name
  &#125;
 
  triggers &#123; pollSCM(&#39;H/10 &#42; &#42; &#42; &#42;&#39;) 

 &#125;

  options &#123;
    buildDiscarder(logRotator(numToKeepStr&#58; &#39;5&#39;))
    checkoutToSubdirectory(&#39;hugo&#39;)
  &#125;
 
  stages &#123;
    stage(&#39;Checkout www repo&#39;) &#123;
      steps &#123;
        dir(&#39;www&#39;) &#123;
            sshagent(&#91;&#39;git.eclipse.org&#45;bot&#45;ssh&#39;&#93;) &#123;
                sh &#39;&#39;&#39;
                    git clone ssh&#58;//genie.$&#123;PROJECT_NAME&#125;@git.eclipse.org&#58;29418/www.eclipse.org/$&#123;PROJECT_NAME&#125;.git .
                    git checkout $&#123;BRANCH_NAME&#125;
                &#39;&#39;&#39;
            &#125;
        &#125;
      &#125;
    &#125;
    stage(&#39;Build website (master) with Hugo&#39;) &#123;
      when &#123;
        branch &#39;master&#39;
      &#125;
      steps &#123;
        container(&#39;hugo&#39;) &#123;
            dir(&#39;hugo&#39;) &#123;
                sh &#39;hugo &#45;b https&#58;//www.eclipse.org/$&#123;PROJECT_NAME&#125;/&#39;
            &#125;
        &#125;
      &#125;
    &#125;
    stage(&#39;Build website (staging) with Hugo&#39;) &#123;
      when &#123;
        branch &#39;staging&#39;
      &#125;
      steps &#123;
        container(&#39;hugo&#39;) &#123;
            dir(&#39;hugo&#39;) &#123;
                sh &#39;hugo &#45;b https&#58;//staging.eclipse.org/$&#123;PROJECT_NAME&#125;/&#39;
            &#125;
        &#125;
      &#125;
    &#125;
    stage(&#39;Push to $env.BRANCH_NAME branch&#39;) &#123;
      when &#123;
        anyOf &#123;
          branch &quot;master&quot;
          branch &quot;staging&quot;
        &#125;
      &#125;
      steps &#123;
        sh &#39;rm &#45;rf www/&#42; &amp;&amp; cp &#45;Rvf hugo/public/&#42; www/&#39;
        dir(&#39;www&#39;) &#123;
            sshagent(&#91;&#39;git.eclipse.org&#45;bot&#45;ssh&#39;&#93;) &#123;
                sh &#39;&#39;&#39;
                git add &#45;A
                if &#33; git diff &#45;&#45;cached &#45;&#45;exit&#45;code&#59; then
                  echo &quot;Changes have been detected, publishing to repo &#39;www.eclipse.org/$&#123;PROJECT_NAME&#125;&#39;&quot;
                  git config user.email &quot;$&#123;PROJECT_NAME&#125;&#45;[email protected]&quot;
                  git config user.name &quot;$&#123;PROJECT_BOT_NAME&#125;&quot;
                  git commit &#45;m &quot;Website build $&#123;JOB_NAME&#125;&#45;$&#123;BUILD_NUMBER&#125;&quot;
                  git log &#45;&#45;graph &#45;&#45;abbrev&#45;commit &#45;&#45;date&#61;relative &#45;n 5
                  git push origin HEAD&#58;$&#123;BRANCH_NAME&#125;
                else
                  echo &quot;No changes have been detected since last build, nothing to publish&quot;
                fi
                &#39;&#39;&#39;
            &#125;
        &#125;
      &#125;
    &#125;
  &#125;
&#125;

Finally, you can create a multibranch pipeline job on your project's Jenkins instance. It will automatically be triggered on every new push to your Hugo source repository, build the website and push it to the git.eclipse.org/www.eclipse.org/&amp;lt&#59;project_name&amp;gt&#59;.git repository. As mentioned above, the Eclipse Foundation website's infrastructure will eventually pull the content of the latter and your website will be published and available on http://www.eclipse.org/<project_name>.

If you don't have a Jenkins instance already, ask for one. If you need assistance with the process, open a ticket.

How to accept fork contribution?

By default, Jenkins project configurations using the GitLab Branch Source plugin are set up with 'Trusted Members' as the default option.

Definition of 'trusted members': [Recommended] Discover merge requests from forked projects whose authors have Developer/Maintainer/Owner access levels in the origin project.

To accept contributions from contributors with fork project, the project should:

  • Configure the CI project by changing 'Discover merge requests from forks' to 'Members'.
  • The project lead should add the user to the list of collaborators in PMI.
  • The contributor should change the forked project's visibility to public.

Cluster migration

See CBI/Jenkins_Migration_FAQ