-
Notifications
You must be signed in to change notification settings - Fork 69
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-55568] Add support of passing Jenkins Core version from pom.xml #72
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @fcojfernandez !
The code itself looks good, but I have some concerns about the behavior.
- The code still requires the
war
section to be present in the config YAML, even if it is unused - It will be a breaking change for users who already use
pom.xml
as an input and use Jenkins core version defined in YAML. . For example, https://github.com/jenkinsci/ci.jenkins.io-runner
My proposal would be to slightly alter the logic so that...
- Jenkins core version in packager-config.yml is a priority. A warning is printed if it overrides pom.xml
- If
war
section is not specified, pom.xml or BOM are used - If Jenkins WAR is not specified anywhere, the build just fails
I would like to also note that you might want to use jenkins-war.version
if it is specified. Jenkins Core and Jenkins WAR versions may be different in some cases (e.g. timestamped snapshots)
@@ -181,6 +182,13 @@ public void overrideByPOM(@Nonnull File tmpDir, @Nonnull File pom, final boolean | |||
} | |||
|
|||
MavenHelper helper = new MavenHelper(this); | |||
String jenkinsVersion = model.getProperties().getProperty("jenkins.version"); | |||
if (StringUtils.isNotBlank(jenkinsVersion)) { | |||
ComponentReference core = new ComponentReference(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to specify other info here, such as the coordinates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's set in war = core.toWARDependencyInfo();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I don't see any assignments done to such object, I guess it's created to content core references.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -143,6 +143,7 @@ public void downloadJAR(File buildDir, DependencyInfo dep, String version, File | |||
DependencyInfo dep = new DependencyInfo(); | |||
dep.groupId = dependencyData[0].trim(); | |||
dep.artifactId = dependencyData[1].trim(); | |||
dep.type = dependencyData[2].trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be empty (as in the DependencyInfo changes)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dependency:list
always informs the type, so here it cannot be null. In DependencyInfo
I've checked the nullability just in case it could be used in other way.
@oleg-nenashev regarding your concerns:
I've kept the current behaviour as with BOM. If the BOM or POM specify the jenkins version, it's overridden.
This is the opposite behaviour comparing with plugins. IMHO, it makes sense to keep the coherence and the same behaviour. In fact, if the core is set in BOM, it already override the war section.
As I've mentioned before, I've kept the current behaviour. I can check what will happen (I think it's going to fail) and if not, I think this part makes sense. Regarding your last comment, I'm not sure to be following you:
Are you proposing:
What about the dependencies? IMO, they should prevail before the properties. |
It's currently failing, but the message does not give detailed information. My last commit is to check and throw an exception with a better information message |
With my last commit I've added the support for reading the property since I agree with @oleg-nenashev that it makes sense:
The dependency section in pom prevails. |
The problem is that it will be a breaking change for existing users (core from packager-config.yml would be used before the change, pom.xml would be used afterwards). And there is no opt-out offered. |
@oleg-nenashev I mean that dependency section prevails over the properties. Regarding the pom prevailing over the yml, I see your point but it's the same behaviour than BOM has got: BOM overrides the war section, so for me, the natural behaviour for POM would be to mimic BOM. It seems weird to me if they behave differently. |
I agree. I would be interested to work on a new major release with better YAML format (e.g. multi-source input and templating from JIRA), but it is not in the scope for now. I would just like to retain some level of compatibility if possible for now until the rework happens. Maybe we could just have a |
You mean a global |
yup |
custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/util/MavenHelper.java
Outdated
Show resolved
Hide resolved
war = null; | ||
String jenkinsVersion = model.getProperties().getProperty("jenkins-war.version"); | ||
if (StringUtils.isBlank(jenkinsVersion)) { | ||
jenkinsVersion = model.getProperties().getProperty("jenkins.version"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it affects, but note that ComponentReference always uses the 'jenkins-war' artifact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the artifact used to explode the war. See here:
Line 221 in 251cc15
war = spec.getCore().toWARDependencyInfo(); |
while the specification is
spec: | |
core: | |
version: 2.118 |
It seems tests are failing? |
Something has interrupted the execution. Seen in the logs of a non-related (to this PR) test:
Last time I saw this error, closing and re-opening didn't work, so I'll make a fake commit |
See JENKINS-55568
Add support of passing Jenkins Core version from pom.xml:
jenkins.version
is specified, the war section in yml file is overridden and ignoredjenkins-core
orjenkins-war
exist, the dependency overrides any other configuration for the core.Besides, the documentation is updated and I've added a test.