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-55568] Add support of passing Jenkins Core version from pom.xml #72

Merged
merged 11 commits into from
Mar 6, 2019

Conversation

fcojfernandez
Copy link
Contributor

See JENKINS-55568

Add support of passing Jenkins Core version from pom.xml:

  • In case the jenkins.version is specified, the war section in yml file is overridden and ignored
  • In case a dependency on jenkins-core or jenkins-war exist, the dependency overrides any other configuration for the core.

Besides, the documentation is updated and I've added a test.

Copy link
Member

@oleg-nenashev oleg-nenashev left a 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();
Copy link

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?

Copy link
Contributor Author

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();

Copy link

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.

Copy link
Contributor Author

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();
Copy link

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)?

Copy link
Contributor Author

@fcojfernandez fcojfernandez Mar 4, 2019

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.

@fcojfernandez
Copy link
Contributor Author

@oleg-nenashev regarding your concerns:

The code still requires the war section to be present in the config YAML, even if it is unused

I've kept the current behaviour as with BOM. If the BOM or POM specify the jenkins version, it's overridden.

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

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.

If Jenkins WAR is not specified anywhere, the build just fails

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:

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)

Are you proposing:

  1. Read jenkins-war.version
  2. If not exists, read jenkins.version

What about the dependencies? IMO, they should prevail before the properties.

@fcojfernandez
Copy link
Contributor Author

fcojfernandez commented Mar 4, 2019

@oleg-nenashev

If Jenkins WAR is not specified anywhere, the build just fails

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

@fcojfernandez
Copy link
Contributor Author

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)

With my last commit I've added the support for reading the property since I agree with @oleg-nenashev that it makes sense:

  1. Read jenkins-war.version
  2. If not exist, read jenkins.version

The dependency section in pom prevails.

@oleg-nenashev
Copy link
Member

@fcojfernandez

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.

@fcojfernandez
Copy link
Contributor Author

@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.
@varyvol any thought? A third opinion would be useful here

@oleg-nenashev
Copy link
Member

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 bomIncludeWar flag or whatever?

@fcojfernandez
Copy link
Contributor Author

You mean a global bomIncludeWar=true to override the war section? So if it's false or it's not specified then the war section is the source for configuring the war; and if it is not true and the war section is missing, then the build fails. This approach would work for me. Is it fine for you?

@oleg-nenashev
Copy link
Member

This approach would work for me. Is it fine for you?

yup

war = null;
String jenkinsVersion = model.getProperties().getProperty("jenkins-war.version");
if (StringUtils.isBlank(jenkinsVersion)) {
jenkinsVersion = model.getProperties().getProperty("jenkins.version");
Copy link

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.

Copy link
Contributor Author

@fcojfernandez fcojfernandez Mar 4, 2019

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:


while the specification is

@varyvol
Copy link

varyvol commented Mar 5, 2019

It seems tests are failing?

@fcojfernandez
Copy link
Contributor Author

Something has interrupted the execution. Seen in the logs of a non-related (to this PR) test:

INFO: Generating Dockerfile

Sending interrupt signal to process

/home/jenkins/workspace/Tools_custom-war-packager_PR-72/jenkinsfile-runner-tests/.jenkinsfile-runner-test-framework/src/cwp/custom-war-packager.inc: line 82: 20627 Terminated              docker build -t "$image_tag" -f "$1/out/tmp/output/Dockerfile" "$1/out/tmp/output/"

Last time I saw this error, closing and re-opening didn't work, so I'll make a fake commit

@fcojfernandez fcojfernandez reopened this Mar 6, 2019
@oleg-nenashev oleg-nenashev merged commit d82ca51 into jenkinsci:master Mar 6, 2019
@fcojfernandez fcojfernandez deleted the JENKINS-55568 branch March 6, 2019 15:58
This pull request was closed.
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

Successfully merging this pull request may close these issues.

3 participants