Skip to content

Commit

Permalink
Merge branch 'master' into yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossg committed Jan 21, 2018
2 parents 318a7ba + 02dbf1e commit de2fd24
Show file tree
Hide file tree
Showing 23 changed files with 259 additions and 321 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,17 @@
CHANGELOG
=========

1.2
-----
* Split credentials classes into new plugin [kubernetes-credentials](https://github.com/jenkinsci/kubernetes-credentials-plugin) [#268](https://github.com/jenkinsci/kubernetes-plugin/pull/268)

1.1.3
-----
* Fix UI support of environment variables [JENKINS-47112](https://issues.jenkins-ci.org/browse/JENKINS-47112) [#273](https://github.com/jenkinsci/kubernetes-plugin/pull/273)
* Missing call to `slave.terminate()` [#256](https://github.com/jenkinsci/kubernetes-plugin/pull/256)
* Rename slave -> agent [#258](https://github.com/jenkinsci/kubernetes-plugin/pull/258)
* Add new line when logging the agent in Jenkins [#267](https://github.com/jenkinsci/kubernetes-plugin/pull/267)

1.1.2
-----
* Namespace is erroneously autodetected as 'default' [#261](https://github.com/jenkinsci/kubernetes-plugin/pull/261)
Expand Down
18 changes: 10 additions & 8 deletions README.md
Expand Up @@ -416,7 +416,13 @@ Integration tests will use the currently configured context autodetected from ku

Run `mvn clean install` and copy `target/kubernetes.hpi` to Jenkins plugins folder.

## Integration Tests with Minikube
## Running Kubernetes Integration Tests

Please note that the system you run `mvn` on needs to be reachable from the cluster.
If you see the agents happen to connect to the wrong host, see you can use
`jenkins.host.address` as mentioned above.

### Integration Tests with Minikube

For integration tests install and start [minikube](https://github.com/kubernetes/minikube).
Tests will detect it and run a set of integration tests in a new namespace.
Expand All @@ -426,11 +432,11 @@ to be accessible from the kubernetes cluster.
By default Jenkins will listen on `192.168.64.1` interface only, for security reasons.
If your minikube is not running in that network, pass `connectorHost` to maven, ie.

mvn clean install -DconnectorHost=$(minikube ip | sed -e 's/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1.1/')
mvn clean install -DconnectorHost=$(minikube ip | sed -e 's/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1.1/')

If you don't mind others in your network being able to use your test jenkins you could just use this:

mvn clean install -DconnectorHost=0.0.0.0
mvn clean install -DconnectorHost=0.0.0.0

Then your test jenkins will listen on all ip addresses so that the build pods will be able to connect from the pods in your minikube VM to your host.

Expand All @@ -440,7 +446,7 @@ system property to the (host-only or NAT) IP of your host:

mvn clean install -Djenkins.host.address=192.168.99.1

## Integration Tests in a Different Cluster
### Integration Tests in a Different Cluster

Ensure you create the namespaces and roles with the following commands, then run the tests
in namespace `kubernetes-plugin` with the service account `jenkins`
Expand All @@ -458,10 +464,6 @@ kubectl apply -n kubernetes-plugin-test-overridden-namespace -f src/test/kuberne
kubectl apply -n kubernetes-plugin-test-overridden-namespace2 -f src/test/kubernetes/service-account.yml
```

Please note that the system you run `mvn` on needs to be reachable from the cluster.
If you see the agents happen to connect to the wrong host, see you can use
`jenkins.host.address` as mentioned above.

# Docker image

Docker image for Jenkins, with plugin installed.
Expand Down
19 changes: 13 additions & 6 deletions pom.xml
Expand Up @@ -8,7 +8,7 @@

<groupId>org.csanchez.jenkins.plugins</groupId>
<artifactId>kubernetes</artifactId>
<version>1.1.3-SNAPSHOT</version>
<version>1.1.4-SNAPSHOT</version>
<name>Kubernetes plugin</name>
<description>Jenkins plugin to run dynamic agents in a Kubernetes cluster</description>
<packaging>hpi</packaging>
Expand Down Expand Up @@ -52,7 +52,8 @@

<!-- jenkins plugins versions -->
<jenkins-basic-steps.version>2.3</jenkins-basic-steps.version>
<jenkins-credentials.version>2.1.7</jenkins-credentials.version>
<jenkins-credentials.version>2.1.11</jenkins-credentials.version>
<jenkins-kubernetes-credentials.version>0.2.0</jenkins-kubernetes-credentials.version>
<jenkins-durable-task.version>1.16</jenkins-durable-task.version>
<jenkins-durable-task-step.version>2.11</jenkins-durable-task-step.version>
<jenkins-structs.version>1.6</jenkins-structs.version>
Expand Down Expand Up @@ -83,9 +84,9 @@

<!-- required plugins -->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>${jenkins-credentials.version}</version>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>kubernetes-credentials</artifactId>
<version>${jenkins-kubernetes-credentials.version}</version>
</dependency>

<dependency> <!-- OnceRetentionStrategy -->
Expand Down Expand Up @@ -201,9 +202,15 @@
</dependency>
</dependencies>

<!-- just to fix enforcer RequireUpperBoundDeps -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>${jenkins-credentials.version}</version>
</dependency>

<!-- just to fix enforcer RequireUpperBoundDeps -->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
Expand Down
@@ -1,11 +1,15 @@
package org.csanchez.jenkins.plugins.kubernetes;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

import org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;
import hudson.model.Descriptor;
import hudson.model.DescriptorVisibilityFilter;

/**
* Deprecated, use KeyValueEnvVar
Expand All @@ -23,20 +27,23 @@ public String toString() {
return "ContainerEnvVar [getValue()=" + getValue() + ", getKey()=" + getKey() + "]";
}

public Descriptor<KeyValueEnvVar> getDescriptor() {
return new DescriptorImpl();
}

@Extension
@Symbol("containerEnvVar")
/**
* deprecated, use envVar
*/
public static class DescriptorImpl extends Descriptor<KeyValueEnvVar> {
public static class DescriptorImpl extends KeyValueEnvVar.DescriptorImpl {
@Override
public String getDisplayName() {
return "Environment Variable";
return "[Deprecated: Use Environment Variable] Container Environment Variable";
}
}

@Extension
public static class DescriptorVisibilityFilterImpl extends DescriptorVisibilityFilter {
@Override
public boolean filter(@CheckForNull Object context, @Nonnull Descriptor descriptor) {
return !(descriptor instanceof ContainerEnvVar.DescriptorImpl);
}
}
}
Expand Up @@ -8,6 +8,8 @@
import org.apache.commons.lang.StringUtils;
import org.csanchez.jenkins.plugins.kubernetes.model.TemplateEnvVar;
import org.jenkinsci.Symbol;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

Expand All @@ -16,6 +18,8 @@
import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import hudson.model.DescriptorVisibilityFilter;
import jenkins.model.Jenkins;

public class ContainerTemplate extends AbstractDescribableImpl<ContainerTemplate> implements Serializable {

Expand Down Expand Up @@ -218,5 +222,11 @@ public static class DescriptorImpl extends Descriptor<ContainerTemplate> {
public String getDisplayName() {
return "Container Template";
}

@SuppressWarnings("unused") // Used by jelly
@Restricted(DoNotUse.class) // Used by jelly
public List<? extends Descriptor> getEnvVarsDescriptors() {
return DescriptorVisibilityFilter.apply(null, Jenkins.getInstance().getDescriptorList(TemplateEnvVar.class));
}
}
}
Expand Up @@ -27,6 +27,7 @@
import jenkins.tasks.SimpleBuildWrapper;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.kubernetes.credentials.TokenProducer;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
Expand Down
Expand Up @@ -25,10 +25,14 @@

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.kubernetes.credentials.OpenShiftBearerTokenCredentialImpl;
import org.jenkinsci.plugins.kubernetes.credentials.OpenShiftTokenCredentialImpl;
import org.jenkinsci.plugins.kubernetes.credentials.TokenProducer;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;

import com.cloudbees.plugins.credentials.Credentials;
import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.common.StandardCertificateCredentials;
Expand All @@ -44,6 +48,8 @@
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.Util;
import hudson.init.InitMilestone;
import hudson.init.Initializer;
import hudson.model.Computer;
import hudson.model.Descriptor;
import hudson.model.Label;
Expand Down Expand Up @@ -508,6 +514,16 @@ public String getDisplayName() {
return "Kubernetes";
}

@Initializer(before = InitMilestone.PLUGINS_STARTED)
public static void addAliases() {
Jenkins.XSTREAM2.addCompatibilityAlias(
"org.csanchez.jenkins.plugins.kubernetes.OpenShiftBearerTokenCredentialImpl",
OpenShiftBearerTokenCredentialImpl.class);
Jenkins.XSTREAM2.addCompatibilityAlias(
"org.csanchez.jenkins.plugins.kubernetes.OpenShiftTokenCredentialImpl",
OpenShiftTokenCredentialImpl.class);
}

public FormValidation doTestConnection(@QueryParameter String name, @QueryParameter String serverUrl, @QueryParameter String credentialsId,
@QueryParameter String serverCertificate,
@QueryParameter boolean skipTlsVerify,
Expand Down
Expand Up @@ -34,6 +34,7 @@
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.kubernetes.credentials.TokenProducer;

/**
* @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
Expand Down

0 comments on commit de2fd24

Please sign in to comment.