-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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-50282] Allow creating Pod templates from yaml #275
Conversation
This is awesome. I am a huge supporter of this being a feature. 👍 This would mean I don't need to add explicit support for using taints/tolerations and other things, making many things easier! Will the JNLP container be merged into the resulting pod template automatically with this? |
Yes, if yaml doesn't include a |
So we use a jnlp container. Correct me if Im wrong, if the container is a jnlp container, it will not be merged? |
Big. Would also be nice to be able to load it from a file rather than as a string. |
ALso, what does this mean for the declarative step? If it supported the yaml form, it would fix most of my issues with the declarative steps, assuming you could also use |
The rules from combination parent/yaml Pod and child Pod are set in kubernetes-plugin/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtils.java Line 163 in 07cb5e4
Containers are also merged if present in both parent and child with the same name To read from file instead of inline just use |
return this; | ||
} | ||
|
||
@Deprecated |
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.
Why is a new deprecated method being added?
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 one is not new, the new one is public Pod build()
This is a great addition, but adding a yaml template for 5+ Jenkinsfiles quickly becomes a chore... It would have been so nice if it was possible to set the template from the global Jenkins configuration (since all our jobs share the same settings). Maybe it already is, but I can not seem to find it. Maybe I am speaking out of line, if I am I apologize. Thanks for all your great work! |
That just needs the jelly UI code, PRs welcome |
@bbzg You can use a Jenkins shared library to define a function that keeps all that logic in a single place? |
@siwyd Hmm, that's a good idea actually since we already have that for other stuff. Thanks! |
This schedules a pod but it does not get any of the attributes from the YAML I also tried without "inheritFrom" and used name: "default", but with the same result. (I am using scripted pipeline btw) Any pointers would be greatly appreciated. Edit: |
I finally got it working with these settings
And in the global configuration for the Kubernetes plugin I set |
I think this change has broken something. I am not using this new feature, but a plugin upgrade from 1.4.1 to 1.5 and a pod with an
Jenkins LTS latest |
This is tracked as https://issues.jenkins-ci.org/browse/JENKINS-50525 What would be helpful is a test with an example that fails in https://github.com/jenkinsci/kubernetes-plugin/tree/master/src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline to |
@carlossg any thoughts about exposing this in the config.xml (so you can paste a pod template yaml into the k8s cloud plugin config ui, instead of having to define it in your pipeline)? Or is this already possible and i'm missing it? /cc @gabemontero |
it's just a matter of adding a new |
@carlossg we might be able to carve some cycles from @gabemontero to do it in the next few weeks. |
i cannot use it like this :
?? it;s not woking for me |
@shdowofdeath It works if you use the 'yaml' attribute |
To avoid having to manually add fields for all possible options current and future, just pass the yaml to be used as base.
Yaml is merged with other fields (if set) as it if were a parent Podtemplate