-
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
Allow nesting of templates for inheritance. #94
Conversation
Does this feature actually work? Cause I can't get it to work as documented. First the documentation has a few errors (syntax errors). Outside of that I have the following
#!/usr/bin/groovy def call(Map parameters = [:], body) { def defaultLabel = 'docker' def dockerImage = parameters.get('dockerImage', 'docker:17.06.0-ce-git') podTemplate(label: "label",
|
@matthewceroni: I recall this feature having some issues in 0.11, but I expect it to work fine in 0.12. It's something that I've been extensively using the last couple of months (using a build straight from master). Note: When the templates are internally composed they are looked up by name, so make sure you also add a name to your templates. I think that we need to clarify that in the docs. |
By name you mean the label that is set for each podTemplate? Assuming they must match. Or is there another parameter? |
There is an other string parameter called |
|
So I installed the latest plugin from master (version 0.13-SNAPSHOT) Then I tested the following PIPELINE
But same issue as before. The POD gets created by only the docker container is present (plus the default JNLP). The maven container does not get included. From the PIPELINE above can you see any issue? I set the name to match and even tried having the label match or not match. |
Just a guess but it maybe the |
I have actually looked at the example you pasted. But that isn't using the POD template nesting feature. |
@matthewceroni: you can't use the same name on both templates. Use unique names and you should be fine. |
The podTemplate(name: .. ) settings needs to differ?
Like that? Cause I did that and still doesn't work. |
@matthewceroni: Yeah, this seems right and it should work 0.12 onwards. |
Can you try and also use a unique value for the label too? |
@iocanel I believe I have tried using a unique label but will try again. In the mavenTemplate example they are over-writing the maven container. As the nested (possible) podTemplate contains the same maven container just with different settings. I am trying to add additional containers. Is that possible or is the nesting feature only able to over-write containers that are in the outter podTemplate. |
It's possible to both add and replace. More real world examples:
In both examples the idea is the same, use simple functions to define pod templates, and blend them together using nesting. |
The Syndesis Rest examples make sense to me. So I tried to follow them. https://github.com/Smarsh/pipeline-library/tree/master/vars And my test Jenkinsfile
Still nothing. This is frustrating me since it seems so straight forward. What I do notice is that if you set the name on podTemplate the POD it creates starts with that name (ie: maven-######). The only thing I don't have that the above examples have is setting the defaultLabel (ex: def defaultLabel = buildId('maven')) as function buildId is undefined but I don't think that should really matter. |
Ok, I think I just got it to work. The maven podTemplate has default label of maven. The docker podTemplate has a default label of docker. As you can see in the above I set node('maven') and in doing so it only provisioned the maven podTemplate. If i set that to node('docker') it worked. My understanding of the parameter to node was to match the label the slave had so I always tried to make the label match on all the podTemplate. But looking at the examples that isn't required. In the Syndesis example they wrapped their calls to their template in node { } but if I do that the pod never gets provisioned and the PIPELINE just sits there with "Waiting for next available executor" |
Is this functionality supported when using declarative pipeline? If so does anyone have an example? |
No description provided.