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

Added tool installations to the pod template. #85

Merged
merged 6 commits into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public KubernetesSlave(PodTemplate template, String nodeDescription, KubernetesC
labelStr == null ? null : labelStr,
new JNLPLauncher(),
new OnceRetentionStrategy(cloud.getRetentionTimeout()),
Collections.<NodeProperty<Node>> emptyList());
template.getNodeProperties());

// this.pod = pod;
this.cloud = cloud;
Expand All @@ -68,7 +68,7 @@ public KubernetesSlave(PodTemplate template, String nodeDescription, KubernetesC
label == null ? null : label.toString(),
new JNLPLauncher(),
new OnceRetentionStrategy(cloud.getRetentionTimeout()),
Collections.<NodeProperty<Node>> emptyList());
template.getNodeProperties());

// this.pod = pod;
this.cloud = cloud;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.csanchez.jenkins.plugins.kubernetes;

import hudson.tools.ToolLocationNodeProperty;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -73,6 +74,8 @@ public class PodTemplate extends AbstractDescribableImpl<PodTemplate> {

private final List<PodImagePullSecret> imagePullSecrets = new ArrayList<PodImagePullSecret>();

private List<ToolLocationNodeProperty> nodeProperties;

@DataBoundConstructor
public PodTemplate() {
}
Expand Down Expand Up @@ -274,6 +277,19 @@ public void setImagePullSecrets(List<PodImagePullSecret> imagePullSecrets) {
this.imagePullSecrets.addAll(imagePullSecrets);
}

@DataBoundSetter
public void setNodeProperties(List<ToolLocationNodeProperty> nodeProperties){
this.nodeProperties = nodeProperties;
}

@Nonnull
public List<ToolLocationNodeProperty> getNodeProperties(){
if (nodeProperties == null) {
return Collections.emptyList();
}
return nodeProperties;
Copy link
Contributor

Choose a reason for hiding this comment

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

should return emptyList if nodeProperties is null ?

please set the @Nonnull annotation if that's the case

}

@Deprecated
public String getResourceRequestMemory() {
return getFirstContainer().map(ContainerTemplate::getResourceRequestMemory).orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<f:textbox/>
</f:entry>

<f:descriptorList title="${%Node Properties}" descriptors="${h.getNodePropertyDescriptors(descriptor.clazz)}" field="nodeProperties" />

</f:advanced>

</j:jelly>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public class KubernetesPipelineTest {

@BeforeClass
public static void configureCloud() throws Exception {
// do not run if minikube is not running
assumeMiniKube();

cloud.setServerUrl(new URL("https", miniKubeIp(), 8443, "").toExternalForm());
cloud.setNamespace("default");
cloud.connect();
Expand All @@ -102,8 +105,6 @@ public static void configureCloud() throws Exception {

@Test
public void runInPod() throws Exception {
// do not run if minikube is not running
assumeMiniKube();

// Slaves running in Kubernetes (minikube) need to connect to this server, so localhost does not work
URL url = r.getURL();
Expand Down