-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make variables optional Signed-off-by: Kanstantsin Shautsou <[email protected]> * WIP * wip * only for cloud slave * Findbugs * Findbugs
- Loading branch information
Showing
6 changed files
with
198 additions
and
21 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
95 changes: 95 additions & 0 deletions
95
yet-another-docker-plugin/src/main/java/com/github/kostyasha/yad/DockerNodeProperty.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,95 @@ | ||
package com.github.kostyasha.yad; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Node; | ||
import hudson.slaves.NodeProperty; | ||
import hudson.slaves.NodePropertyDescriptor; | ||
import org.jenkinsci.Symbol; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* @author Kanstantsin Shautsou | ||
*/ | ||
public class DockerNodeProperty extends NodeProperty<Node> { | ||
|
||
private String containerId = "DOCKER_CONTAINER_ID"; | ||
private boolean containerIdCheck = true; | ||
|
||
private String cloudId = "JENKINS_CLOUD_ID"; | ||
private boolean cloudIdCheck = true; | ||
|
||
private String dockerHost = "DOCKER_HOST"; | ||
private boolean dockerHostCheck = true; | ||
|
||
|
||
// Default UI | ||
public DockerNodeProperty() { | ||
} | ||
|
||
public DockerNodeProperty(String containerId, String cloudId, String dockerHost) { | ||
this.containerId = containerId; | ||
this.containerIdCheck = true; | ||
|
||
this.cloudId = cloudId; | ||
this.cloudIdCheck = true; | ||
|
||
this.dockerHost = dockerHost; | ||
this.dockerHostCheck = true; | ||
} | ||
|
||
// Crazy UI binding | ||
@DataBoundConstructor | ||
public DockerNodeProperty(String containerId, boolean containerIdCheck, | ||
String cloudId, boolean cloudIdCheck, | ||
String dockerHost, boolean dockerHostCheck) { | ||
this.containerId = containerId; | ||
this.containerIdCheck = containerIdCheck; | ||
|
||
this.cloudId = cloudId; | ||
this.cloudIdCheck = cloudIdCheck; | ||
|
||
this.dockerHost = dockerHost; | ||
this.dockerHostCheck = dockerHostCheck; | ||
} | ||
|
||
public String getContainerId() { | ||
return containerId; | ||
} | ||
|
||
public String getCloudId() { | ||
return cloudId; | ||
} | ||
|
||
public String getDockerHost() { | ||
return dockerHost; | ||
} | ||
|
||
public boolean isContainerIdCheck() { | ||
return containerIdCheck; | ||
} | ||
|
||
public boolean isCloudIdCheck() { | ||
return cloudIdCheck; | ||
} | ||
|
||
public boolean isDockerHostCheck() { | ||
return dockerHostCheck; | ||
} | ||
|
||
@Symbol("dockerEnvVars") | ||
@Extension | ||
public static class DescriptorImpl extends NodePropertyDescriptor { | ||
@Override | ||
public boolean isApplicable(Class<? extends Node> targetType) { | ||
return targetType.isAssignableFrom(DockerSlave.class); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getDisplayName() { | ||
return "Docker variables"; | ||
} | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
...ocker-plugin/src/main/resources/com/github/kostyasha/yad/DockerNodeProperty/config.groovy
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,44 @@ | ||
package com.github.kostyasha.yad.DockerNodeProperty | ||
|
||
import com.github.kostyasha.yad.DockerNodeProperty | ||
import lib.FormTagLib | ||
|
||
def f = namespace(FormTagLib); | ||
def st = namespace("jelly:stapler") | ||
|
||
if (instance == null) { | ||
instance = new DockerNodeProperty() | ||
} | ||
|
||
// intend somehow | ||
f.block() { | ||
f.optionalBlock( | ||
title: _("Docker Container ID"), | ||
field: "containerIdCheck", | ||
inline: true | ||
) { | ||
f.entry(title: "Variable name") { | ||
f.textbox(field: "containerId") | ||
} | ||
} | ||
|
||
f.optionalBlock( | ||
title: _("Docker Cloud ID"), | ||
field: "cloudIdCheck", | ||
inline: true | ||
) { | ||
f.entry(title: "Variable name") { | ||
f.textbox(field: "cloudId") | ||
} | ||
} | ||
|
||
f.optionalBlock( | ||
title: _("Docker Host URL"), | ||
field: "dockerHostCheck", | ||
inline: true | ||
) { | ||
f.entry(title: "Variable name") { | ||
f.textbox(field: "dockerHost") | ||
} | ||
} | ||
} |