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

[JENKINS-58770] Manage all BOM lines in one Git branch #107

Merged
merged 12 commits into from
Sep 26, 2019
Merged
9 changes: 2 additions & 7 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
_extends: .github
tag-template: bom-$NEXT_PATCH_VERSION
version-template: $MAJOR.$MINOR.$PATCH
branches:
- master
- 2.164.x
- 2.150.x
- 2.138.x
tag-template: bom-$NEXT_MAJOR_VERSION
version-template: $MAJOR
32 changes: 17 additions & 15 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,37 @@ def mavenEnv(body) {
}

def plugins
def lines

stage('prep') {
mavenEnv {
checkout scm
def tmp = pwd tmp: true
withEnv(["SAMPLE_PLUGIN_OPTS=-Dmaven.repo.local=$tmp/m2repo -Dset.changelist -Dexpression=changelist -Doutput=$tmp/changelist help:evaluate"]) {
withEnv(['SAMPLE_PLUGIN_OPTS=-Dset.changelist']) {
sh 'bash prep.sh'
}
dir('sample-plugin/target') {
dir('target') {
plugins = readFile('plugins.txt').split(' ')
stash name: 'pct', includes: 'megawar.war,pct.jar'
lines = readFile('lines.txt').split(' ')
stash name: 'pct', includes: 'pct.jar'
lines.each {stash name: "megawar-$it", includes: "megawar-${it}.war"}
}
stash name: 'ci', includes: 'pct.sh'
def changelist = readFile("$tmp/changelist")
dir("$tmp/m2repo") {
archiveArtifacts artifacts: "**/*$changelist/*$changelist*", excludes: '**/sample/'
}
infra.prepareToPublishIncrementals()
}
}

branches = [failFast: true]
plugins.each { plugin ->
branches["pct-$plugin"] = {
mavenEnv {
deleteDir()
unstash 'ci'
unstash 'pct'
withEnv(["PLUGINS=$plugin"]) {
sh 'bash pct.sh'
lines.each {line ->
branches["pct-$plugin-$line"] = {
mavenEnv {
deleteDir()
unstash 'ci'
unstash 'pct'
unstash "megawar-$line"
withEnv(["PLUGINS=$plugin", "LINE=$line"]) {
sh 'mv megawar-$LINE.war megawar.war && bash pct.sh'
}
}
}
}
Expand Down
50 changes: 15 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,51 +131,31 @@ It is unusual but possible for cross-component incompatibilities to only be visi

## LTS lines

The `master` branch should track the current LTS line.
A few historical lines are also tracked by branches,
for use from plugins which are not yet ready to depend on the latest.
Each line is released independently with `maven-release-plugin`.
When a new LTS line is released (`jenkins-2.xxx.1`),
a new BOM branch should be cut from the current `master`,
and `master` made to track the new line.

The CI build (or just `mvn test`) will fail if some managed plugins are too new for the LTS line.
A separate BOM artifact if available for the current LTS line and a few historical lines.
When a new LTS line is released (`jenkins-2.nnn.1`),
the main definition should be moved into its BOM,
and the the previous BOM made to inherit from it.
Older BOMs should only specify plugin version overrides compared to the next-newer BOM.
`sample-plugin` also needs a POM profile for each supported line.

The CI build (or just `mvn test -P2.nnn.x`) will fail if some managed plugins are too new for the LTS line.
[This script](https://gist.github.com/jglick/0a85759ea65f60e107ac5a85a5032cae)
is a handy way to find the most recently released plugin version compatible with a given line,
according to the `jenkins-infra/update-center2` (which currently maintains releases for the past five lines).

General changes (such as to CI infrastructure), and most dependency updates, should be done in `master` first.
Commits from `master` should be merged into the next older LTS branch,
and from there into the branch one older, and so on.
This ensures that CI-related changes propagate to all branches without manual copy-and-paste.
Merge conflicts should be resolved in favor of the `HEAD`,
so that the branches differ from `master` only in POMs (and perhaps in sample plugin code).

To be safe, rather than directly pushing merges, prepare them in a PR branch:

```sh
git checkout -b 2.164.x-merge 2.164.x
git merge master
git push fork
# file a PR from youracct:2.164.x-merge → jenkinsci:2.164.x
git checkout -b 2.150.x-merge 2.150.x
git merge 2.164.x-merge
git push fork
# etc.
```

and only merge the PR if CI passes.

## Releasing

`release:prepare` only runs basic tests about plugin versions, not the full PCT.
Therefore be sure to check [commit status for the selected branch](https://github.com/jenkinsci/bom/commits/master)
Therefore be sure to check [commit status](https://github.com/jenkinsci/bom/commits/master)
to ensure that CI builds have passed before cutting a release.

Due to a misconfiguration in Incrementals tooling (JENKINS-58641),
currently after every release you must manually edit `sample-plugin/pom.xml`
and reset `version` to `${revision}${changelist}`
and set `revision` to that of the top-level `pom.xml`.
currently after every release you must manually run

```bash
mvn -f sample-plugin incrementals:reincrementalify
```

Commit and push the result to fix the branch build.

## Incrementals
Expand Down
57 changes: 57 additions & 0 deletions bom-2.138.x/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>parent</artifactId>
<version>${revision}${changelist}</version>
</parent>
<artifactId>bom-2.138.x</artifactId>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bom-2.150.x</artifactId>
<version>${project.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>2.28</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ansicolor</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials-binding</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>mailer</artifactId>
<version>1.23</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ssh-slaves</artifactId>
<version>1.29.4</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>timestamper</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
22 changes: 22 additions & 0 deletions bom-2.150.x/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>parent</artifactId>
<version>${revision}${changelist}</version>
</parent>
<artifactId>bom-2.150.x</artifactId>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bom-2.164.x</artifactId>
<version>${project.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
</project>
27 changes: 27 additions & 0 deletions bom-2.164.x/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>parent</artifactId>
<version>${revision}${changelist}</version>
</parent>
<artifactId>bom-2.164.x</artifactId>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bom-2.176.x</artifactId>
<version>${project.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>2.31</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
18 changes: 1 addition & 17 deletions bom/pom.xml → bom-2.176.x/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>parent</artifactId>
<version>${revision}${changelist}</version>
</parent>
<artifactId>bom</artifactId>
<artifactId>bom-2.176.x</artifactId>
<packaging>pom</packaging>
<properties>
<configuration-as-code-plugin.version>1.30</configuration-as-code-plugin.version>
Expand Down Expand Up @@ -281,20 +281,4 @@
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<executions>
<execution>
<id>flatten</id>
<configuration>
<flattenMode>bom</flattenMode>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
17 changes: 13 additions & 4 deletions local-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
set -euxo pipefail
cd $(dirname $0)

# expects: $PLUGINS, optionally $TEST
# expects: $PLUGINS, optionally $TEST, $LINE

LATEST_LINE=$(ls -1d bom-*.x | sort -rn | head -1 | sed s/bom-//g)
: "${LINE:=$LATEST_LINE}"

export SAMPLE_PLUGIN_OPTS=-Dtest=InjectedTest
bash prep.sh
if [ $LINE \!= $LATEST_LINE ]
then
export SAMPLE_PLUGIN_OPTS="$SAMPLE_PLUGIN_OPTS -P$LINE"
fi
LINEZ=$LINE bash prep.sh

rm -rf target/local-test
mkdir target/local-test
cp -v sample-plugin/target/{megawar.war,pct.jar} pct.sh target/local-test
cp -v target/pct.jar pct.sh target/local-test
cp -v target/megawar-$LINE.war target/local-test/megawar.war

if [ -v TEST ]
then
Expand All @@ -29,11 +37,12 @@ then
-e MAVEN_OPTS=-Duser.home=/var/maven \
-e MAVEN_CONFIG=/var/maven/.m2 \
-e PLUGINS=$PLUGINS \
-e LINE=$LINE \
-e EXTRA_MAVEN_PROPERTIES=$EXTRA_MAVEN_PROPERTIES \
--entrypoint bash \
jenkins/jnlp-agent-maven \
-c "trap 'chown -R $(id -u):$(id -g) /pct /var/maven/.m2/repository' EXIT; bash /pct/pct.sh"
else
export EXTRA_MAVEN_PROPERTIES
bash target/local-test/pct.sh
LINE=$LINE bash target/local-test/pct.sh
fi
12 changes: 10 additions & 2 deletions pct.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euxo pipefail
cd $(dirname $0)

# expects: megawar.war, pct.war, $PLUGINS
# expects: megawar.war, pct.war, $PLUGINS, $LINE

rm -rf pct-work pct-report.xml

Expand Down Expand Up @@ -55,5 +55,13 @@ rm -fv pct-work/durable-task/target/surefire-reports/TEST-org.jenkinsci.plugins.
rm -fv pct-work/git-client/target/surefire-reports/TEST-hudson.plugins.git.GitExceptionTest.xml
# TODO fails for one reason in (non-PCT) official sources, run locally; and for another reason in PCT in Docker; passes in official sources in Docker, or locally in PCT
rm -fv pct-work/git-client/target/surefire-reports/TEST-org.jenkinsci.plugins.gitclient.FilePermissionsTest.xml
if [ $LINE = 2.138.x ]
then
# TODO pending backport of https://github.com/jenkinsci/workflow-durable-task-step-plugin/pull/95 from 2.29 to 2.28.x, workflow-support 3.x breaks ExecutorStepTest.serialForm
rm -fv pct-work/workflow-durable-task-step/target/surefire-reports/TEST-org.jenkinsci.plugins.workflow.support.steps.ExecutorStepTest.xml
# TODO pending ssh-slaves 1.30.0 with https://github.com/jenkinsci/ssh-slaves-plugin/pull/114 (plus https://github.com/jenkinsci/durable-task-plugin/pull/100):
rm -fv pct-work/ssh-slaves/target/surefire-reports/TEST-hudson.plugins.sshslaves.verifiers.VerificationStrategyConfigurationTest.xml
rm -fv pct-work/ssh-slaves/target/surefire-reports/TEST-hudson.plugins.sshslaves.SSHLauncherTest.xml
fi

# produces: pct-report.xml, **/target/surefire-reports/TEST-*.xml
# produces: **/target/surefire-reports/TEST-*.xml
35 changes: 33 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<version>${revision}${changelist}</version>
<packaging>pom</packaging>
<properties>
<revision>2.176.5</revision>
<revision>3</revision>
<changelist>-SNAPSHOT</changelist>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand All @@ -29,17 +29,48 @@
<tag>${scmTag}</tag>
</scm>
<modules>
<module>bom</module>
<module>bom-2.176.x</module>
<module>bom-2.164.x</module>
<module>bom-2.150.x</module>
<module>bom-2.138.x</module>
<module>sample-plugin</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<executions>
<execution>
<id>flatten</id>
<configuration>
<flattenMode>bom</flattenMode>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<tagNameFormat>bom-@{project.version}</tagNameFormat>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
Expand Down
Loading