forked from jenkinsci/docker-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- DNS setting - Tagging after use - Pushing after use Token Macro for the container ID Builder and publisher to start / stop containers as a part of the build. Signed-off-by: Nigel Magnay <[email protected]>
- Loading branch information
Showing
24 changed files
with
698 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/com/nirima/jenkins/plugins/docker/action/DockerLaunchAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.nirima.jenkins.plugins.docker.action; | ||
|
||
import com.kpelykh.docker.client.DockerClient; | ||
import hudson.model.Action; | ||
import hudson.model.Describable; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Action to record launching of a slave. | ||
*/ | ||
public class DockerLaunchAction implements Action, Serializable, Cloneable{ | ||
|
||
public static class Item { | ||
public final DockerClient client; | ||
public final String id; | ||
|
||
public Item(DockerClient client, String id) { | ||
this.client = client; | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
Item item = (Item) o; | ||
|
||
if (!client.equals(item.client)) return false; | ||
if (!id.equals(item.id)) return false; | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = client.hashCode(); | ||
result = 31 * result + id.hashCode(); | ||
return result; | ||
} | ||
} | ||
|
||
private transient List<Item> running = new ArrayList<Item>(); | ||
|
||
public String getIconFileName() { | ||
return null; | ||
} | ||
|
||
public String getDisplayName() { | ||
return null; | ||
} | ||
|
||
public String getUrlName() { | ||
return null; | ||
} | ||
|
||
public void started(DockerClient client, String containerName) { | ||
running.add( new Item(client, containerName) ); | ||
} | ||
|
||
public void stopped(DockerClient client, String containerName) { | ||
running.remove( new Item(client, containerName) ); | ||
} | ||
|
||
public Iterable<Item> getRunning() { | ||
return running; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/main/java/com/nirima/jenkins/plugins/docker/builder/DockerBuilderControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.nirima.jenkins.plugins.docker.builder; | ||
|
||
import com.google.common.base.Strings; | ||
import com.kpelykh.docker.client.DockerClient; | ||
import com.kpelykh.docker.client.DockerException; | ||
import com.nirima.jenkins.plugins.docker.DockerCloud; | ||
import com.nirima.jenkins.plugins.docker.DockerComputer; | ||
import com.nirima.jenkins.plugins.docker.DockerSlave; | ||
import com.nirima.jenkins.plugins.docker.action.DockerLaunchAction; | ||
import hudson.DescriptorExtensionList; | ||
import hudson.Extension; | ||
import hudson.Launcher; | ||
import hudson.model.*; | ||
import hudson.tasks.BuildStepDescriptor; | ||
import hudson.tasks.Builder; | ||
import hudson.util.ListBoxModel; | ||
import jenkins.model.Jenkins; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import java.io.IOException; | ||
import java.io.Serializable; | ||
import java.util.List; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* Created by magnayn on 29/01/2014. | ||
*/ | ||
public class DockerBuilderControl extends Builder implements Serializable { | ||
private static final Logger LOGGER = Logger.getLogger(DockerBuilderControl.class.getName()); | ||
|
||
public final DockerBuilderControlOption option; | ||
|
||
@DataBoundConstructor | ||
public DockerBuilderControl(DockerBuilderControlOption option) { | ||
this.option = option; | ||
} | ||
|
||
@Override | ||
public DescriptorImpl getDescriptor() { | ||
return (DescriptorImpl) super.getDescriptor(); | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends BuildStepDescriptor<Builder> { | ||
|
||
@Override | ||
public boolean isApplicable(Class<? extends AbstractProject> jobType) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Start/Stop Docker Containers"; | ||
} | ||
|
||
public static DescriptorExtensionList<DockerBuilderControlOption,DockerBuilderControlOptionDescriptor> getOptionList() { | ||
return Jenkins.getInstance() | ||
.<DockerBuilderControlOption,DockerBuilderControlOptionDescriptor>getDescriptorList(DockerBuilderControlOption.class); | ||
} | ||
|
||
} | ||
|
||
|
||
@Override | ||
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { | ||
|
||
try { | ||
option.execute(build); | ||
} catch (DockerException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
// Save the actions | ||
build.save(); | ||
return true; | ||
} | ||
} |
Oops, something went wrong.