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

New Docker approach to test the client #64

Closed
wants to merge 4 commits into from
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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true
add-apt-repository -y ppa:webupd8team/java && \
apt-get update && \
apt-get install -y oracle-java8-installer && \
apt-get install -y curl && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/oracle-jdk8-installer
ADD client/target/swarm-client.jar swarm-client.jar
RUN curl -o http://jenkins:8080/swarm/swarm-client.jar
Copy link
Member

Choose a reason for hiding this comment

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

It needs the Jenkins image to be running when you build the image. IMHO it is not required

Copy link
Contributor Author

@sbaudoin sbaudoin Feb 2, 2018

Choose a reason for hiding this comment

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

On the contrary: the purpose of this is to test the ability to download the Swarm client from Jenkins, so a Jenkins server must be up and running with the Swarm plugin (see the other PR I did)

ENTRYPOINT ["java", "-jar", "swarm-client.jar", "-master", "http://jenkins:8080/"]
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
all: build install run

build:
mvn clean package

install:
rm -rf jenkins_home/plugins/swarm
cp plugin/target/swarm.hpi jenkins_home/plugins

run:
# echo 2.0 > jenkins_home/jenkins.install.UpgradeWizard.state
echo -n 2.0 > jenkins_home/jenkins.install.InstallUtil.lastExecVersion
docker-compose up -d

stop:
docker-compose stop

clean: stop
find jenkins_home -type f ! -name '.keepit' ! -name 'configure-security.groovy' -exec rm -f {} \;
find jenkins_home -depth -mindepth 1 -type d ! -name 'init.groovy.d' ! -name 'plugins' -exec rm -rf {} \;

deep-clean: clean
docker-compose down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ services:
- jenkins

jenkins:
build: jenkins/
image: jenkins/jenkins:lts
ports:
- "8080:8080"
- "50000:50000"
- "36088:36088"
volumes:
- "./jenkins_home:/var/jenkins_home"
Empty file added jenkins_home/.keepit
Empty file.
6 changes: 6 additions & 0 deletions jenkins_home/init.groovy.d/configure-security.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import jenkins.model.Jenkins
import hudson.security.SecurityRealm

def instance = Jenkins.getInstance()
instance.setSecurityRealm(SecurityRealm.NO_AUTHENTICATION)
instance.save()
Empty file added jenkins_home/plugins/.keepit
Empty file.
31 changes: 31 additions & 0 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,37 @@
</developer>
</developers>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>swarm-client</artifactId>
<version>${project.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/${project.artifactId}</outputDirectory>
<destFileName>swarm-client.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package hudson.plugins.swarm;

import hudson.Extension;
import hudson.model.UnprotectedRootAction;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.servlet.ServletException;
import java.io.IOException;

@Extension
public class DownloadClientAction implements UnprotectedRootAction {
public String getIconFileName() {
return null;
}

public String getDisplayName() {
return null;
}

public String getUrlName() {
return "swarm";
}

// serve static resources
@Restricted(NoExternalUse.class)
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
Jenkins.getActiveInstance().getPlugin("swarm").doDynamic(req, rsp);
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
</licenses>

<modules>
<module>plugin</module>
<module>client</module>
<module>plugin</module>
</modules>

<scm>
Expand Down