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

manually specify test host address if automatic discovery fails #190

Closed
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,24 @@ at `DEBUG` level.

# Building and Testing

## manual testing

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

## 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.

Some integration tests run a local jenkins, so the host that runs them needs
to be accessible from the kubernetes cluster.

If your minikube is running in a VM (e.g. on virtualbox) and the host running `mvn`
does not have a public hostname for the VM to access, you can set the `jenkins.host.address`
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
To run the tests in a different kubernetes cluster, get the context with `kubectl config get-contexts` and pass it to Maven with `-Dkubernetes.context`

mvn clean install -Dkubernetes.context=_your-kubernetes-context_
Expand All @@ -335,6 +348,10 @@ ie. for a [minishift](https://github.com/minishift/minishift) context

mvn clean install -Dkubernetes.context=myproject/192-168-64-2:8443/developer

Please note that the system you run `mvn` on needs to be reachable from the cluster.
If you see the slaves 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
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ public static void configureCloud() throws Exception {
public void addCloudToJenkins() throws Exception {
// Slaves running in Kubernetes (minikube) need to connect to this server, so localhost does not work
URL url = r.getURL();
URL nonLocalhostUrl = new URL(url.getProtocol(), InetAddress.getLocalHost().getHostAddress(), url.getPort(),

String hostAddress = System.getProperty("jenkins.host.address");
if (hostAddress == null) {
hostAddress = InetAddress.getLocalHost().getHostAddress();
}
URL nonLocalhostUrl = new URL(url.getProtocol(), hostAddress, url.getPort(),
url.getFile());
JenkinsLocationConfiguration.get().setUrl(nonLocalhostUrl.toString());

Expand Down