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

[FIXED JENKINS-42498] Stop evaluating when conditions at runtime #132

Merged
merged 5 commits into from
Mar 13, 2017

Conversation

abayer
Copy link
Member

@abayer abayer commented Mar 6, 2017

@@ -46,6 +46,8 @@ import static org.jenkinsci.plugins.pipeline.modeldefinition.Utils.createStepsBl
* @author Andrew Bayer
*/
public class ClosureModelTranslator implements MethodMissingWrapper, Serializable {
private static final List<Class> UNTRANSLATED_CLASSES = [StageConditionals.class]
Copy link
Member Author

Choose a reason for hiding this comment

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

Making this a List to check against since we're doing this again for Environment over in #110, and I imagine there'll be more in the future as I gradually kill off the translators.

@abayer abayer added this to the 1.1 milestone Mar 6, 2017
@ghost
Copy link

ghost commented Mar 6, 2017

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@jglick
Copy link
Member

jglick commented Mar 7, 2017

Tried to load the effective diff but it is showing commits from #125, which it should not have been; any idea?

@jglick
Copy link
Member

jglick commented Mar 7, 2017

Maybe just get upstream reviewed & merged, then git merge master here and GitHub will show the incremental diff automatically.

@abayer
Copy link
Member Author

abayer commented Mar 7, 2017

@jglick effective diff fixed now, but yeah, I want to get #125 merged. I would appreciate your thoughts in the meantime, though.

@jglick
Copy link
Member

jglick commented Mar 8, 2017

I am not sure I really understand what it is I am looking at, but it seems that for something like

environment {
  TAG = "$JOB_NAME.$BUILD_NUMBER"
}

previously you would have been passing around a Closure and calling it, and now you are passing around a String and evaluateing it?

In an actual programming language this would be a huge red flag—you are throwing away proper handling of lexical scope, and generally setting the clock back to 1961. But in Declarative I guess it is fine because by the restrictive syntactic rules imposed by the verifier you would not be able to use anything bound into a closure anyway.

Pull the when conditions in by translating them from the AST model,
which does require some evaluation of strings here and there, but
avoids having any Closures in the Describables.
@abayer
Copy link
Member Author

abayer commented Mar 10, 2017

@jglick Yeah, it's not my first choice, but in this particular case, either we're storing a Closure in a Describable and hitting the serialization problem, or we're storing a String and evaluateing it. I think the tradeoffs come down in favor of the String/evaluate option, but I definitely want your input.

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Do not really understand the details, but sounds right in a general way.

*
* @param s The original string
* @return Either the original string, if it already starts/ends with double quotes, or the original string
* prepended/appended with double quotes.
Copy link
Member

Choose a reason for hiding this comment

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

Uh, does this not need to do some kind of escaping?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hrm. Honestly not sure. Lemme think on it.

Copy link
Member Author

Choose a reason for hiding this comment

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

So actually, I don't think it does. We're just taking the string from the original Jenkinsfile source, in effect.

@abayer abayer merged commit 256a473 into jenkinsci:master Mar 13, 2017
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.

2 participants