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

add readYaml step #17

Merged
merged 6 commits into from
Oct 25, 2016
Merged

add readYaml step #17

merged 6 commits into from
Oct 25, 2016

Conversation

philippe-granet
Copy link
Contributor

add readYaml step

@philippe-granet philippe-granet changed the title Master add readYaml step Sep 18, 2016
@philippe-granet
Copy link
Contributor Author

:-(
Build timed out (after 30 minutes). Marking the build as aborted.

How re-launch Jenkins job?

@batmat batmat closed this Sep 21, 2016
@batmat batmat reopened this Sep 21, 2016
Copy link
Member

@rsandell rsandell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I mostly just need clarification on some questions.

/*
* The MIT License (MIT)
*
* Copyright (c) 2016 CloudBees Inc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find you in the CB directory, do you work for CloudBees? If not then you can't claim that CB owns the copyright, you or the company you work for does ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for copy/paste... I will put my name

@@ -33,6 +34,8 @@
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

import hudson.model.Label;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't find any usage of this imported class in your change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I will clean imports

@@ -108,6 +108,11 @@
<artifactId>maven-model</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how common this module is, but there can be issues with other plugins or core providing the same dependency and that could potentially lead to trouble.
If core or any dependant plugin is providing the same you need to shade it or something. For the maven-model dependency my investigation showed that we shouldn't have any dupes, so that was fine. But I don't know about yaml.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maven Shade Plugin doesn't work due to this Maven HPI Plugin bug: https://issues.jenkins-ci.org/browse/JENKINS-31133 ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so we should at least try to estimate if there would be any impact if we include it as is. Normally the dependencies will only clash if the lib is also in core or any plugins that this plugin depends on has it as well. If that's not the case then it should be safe to add as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!StringUtils.isBlank(step.getText())) {
yamlText += "\n\n" + step.getText();
}
Iterable<Object> yaml = new Yaml().loadAll(yamlText);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to follow the code a bit in there, but do you know what type of objects are constructed here? Everything used in the pipeline needs to be Serializable, hence all the hacks in readManifest for example.
Also if there are any custom classes, they also needs to be white listed for the sandbox like in readMavenPom

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To limit objects to standard Java objects like List or Long, I will use SafeConstructor provided by SnakeYAML api:

Yaml yaml = new Yaml(new SafeConstructor());

To ensure that data object is serializable, I will add this:

try(ObjectOutputStream out=new ObjectOutputStream(new ByteArrayOutputStream())){
   out.writeObject(yaml);
};

A java.io.NotSerializableException will be thrown if it isn't serializable

@rsandell rsandell merged commit fcee354 into jenkinsci:master Oct 25, 2016
@rsandell
Copy link
Member

Sorry it took so long

@batmat
Copy link
Member

batmat commented Jan 4, 2019

That vendoring is going to need a fix, because snakeyaml depends on java.sql.Date and that crashes when running on JDK11.

Also, given https://issues.jenkins-ci.org/browse/JENKINS-31133 is now fixed AFAIU, I think this could be already converted into an actual shading instead of a vendoring.

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