STATUS: implemented as of 2017-11-15

Rationale

We have a number of automated processes which make use of the Git repositories as a source of truth:

However, we often have the need to override some of the logic on a per-module basis:

In the future, we may look into other automation, such as

Therefore it is proposed to allow the existence of a Sling module descriptor file in the root of each Git repository. If no descriptor exists, the module is processed by various tools in the default manner. If it exists, the tools must inspect it for custom settings and apply them.

Structure

The module file will be named .sling-module.json . It is a "dotfile" as it is not usually touched during regular development. The JSON format allows easy consumption from various tools, including the Jenkins scripted pipelines. A previous version of the module descriptor used XML, which also allowed comments, but unfortunately it's not easily readable from Jenkins scripted pipelines.

Rather than listing a specification, a full example is provided below. Notice that all JSON members are optional:

{
  "jenkins": {
    "jdks": [
      8,
      9
    ],
    "operatingSystems": [
      "windows",
      "linux"
    ],
    "archivePatterns": [
      "**/sling/logs/error.log"
    ],
    "mavenGoal": "install",
    "additionalMavenParams": "-Dorg.ops4j.pax.url.mvn.repositories=http://repo.maven.apache.org/maven2@id=apache-releases,http://repository.apache.org/content/groups/snapshots-group@snapshots@noreleases@id=apache-snapshots",
    "upstreamProjects": [
      "sling-org-apache-sling-starter"
    ],
    "rebuildFrequency": "@weekly",
    "enabled": false,
    "emailRecipients": [
      "dev@sling.apache.org"
    ],
    "branches": {
      "master": {
        "nodeLabel": "git-websites",
        "additionalMavenParams": "-Ppublish-site -Dmsg=\"Automatic website deployment\""
      }
    },
    "sonarQubeEnabled": false,
    "sonarQubeUseAdditionalMavenParams": false,
    "sonarQubeAdditionalParams": "-PsonarQubeProfile"
  }
}

Description

JSON memberTypePossible Values
jenkins.jdks Array of Numbers8-22
jenkins.operatingSystemsArray of Strings
  • "windows"
  • "linux" (arbitrary Linux distribution)
  • "ubuntu" (always Ubuntu Linux distribution)
  • "linux-arm" (currently Ubuntu ARM)


Default Values

The following JSON members have default values. All others are just not set/empty. Just set them explicitly to a value, if the default does not fit your needs.

JSON memberDefault value
jenkins.jdks 

[ 11, 17, 21 ] 

jenkins.operatingSystems

[ "linux", "windows" ]

jenkins.rebuildFrequency 

"@weekly" 

jenkins.sonarQubeEnabled true 
jenkins.sonarQubeUseAdditionalMavenParamstrue 

(Source: https://github.com/apache/sling-tooling-jenkins/blob/master/vars/slingOsgiBundleBuild.groovy)

Samples

Building with multiple JDK versions and operating systems

{
  "jenkins": {
    "jdks": [8, 11, 17],
    "operatingSystems": ["linux", "windows"]
  }
}

The first JDK/Operating System is always the reference one (i.e. the one from which the build artifacts are deployed to the Maven repository and which are used for the SonarCloud execution)