本文整理汇总了Java中hudson.util.VersionNumber类的典型用法代码示例。如果您正苦于以下问题:Java VersionNumber类的具体用法?Java VersionNumber怎么用?Java VersionNumber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VersionNumber类属于hudson.util包,在下文中一共展示了VersionNumber类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testPermissionWhenParameterizedForMatrixConfig
import hudson.util.VersionNumber; //导入依赖的package包/类
@LocalData
@Test
public void testPermissionWhenParameterizedForMatrixConfig() throws Exception {
// This test fails before Jenkins 1.406
if (new VersionNumber("1.406").isNewerThan(Hudson.getVersion())) return; // Skip
FreeStyleProject p = createProject("testMatrix/FOO=$FOO", null, "", "", false, false, false, true);
ParameterDefinition paramDef = new StringParameterDefinition("FOO", "FOO");
ParametersDefinitionProperty paramsDef = new ParametersDefinitionProperty(paramDef);
p.addProperty(paramsDef);
// Build step should succeed when this parameter expands to a job accessible to
// authenticated users, even when selecting a single matrix config, not the parent job:
FreeStyleBuild b = p.scheduleBuild2(0, new UserCause(),
new ParametersAction(new StringParameterValue("FOO", "foo"))).get();
assertFile(true, "foo.txt", b);
rule.assertBuildStatusSuccess(b);
}
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:18,代码来源:CopyArtifactTest.java
示例2: testPermissionWhenParameterizedForMavenModule
import hudson.util.VersionNumber; //导入依赖的package包/类
@LocalData
@Test
public void testPermissionWhenParameterizedForMavenModule() throws Exception {
// This test fails before Jenkins 1.406
if (new VersionNumber("1.406").isNewerThan(Hudson.getVersion())) return; // Skip
MavenModuleSet mp = setupMavenJob();
mp.addProperty(new AuthorizationMatrixProperty(
Collections.singletonMap(Item.READ, Collections.singleton("authenticated"))));
rule.assertBuildStatusSuccess(mp.scheduleBuild2(0, new UserCause()).get());
FreeStyleProject p = createProject(mp.getName() + "/org.jvnet.hudson.main.test.multimod$FOO",
null, "", "", false, false, false, true);
ParameterDefinition paramDef = new StringParameterDefinition("FOO", "foo");
ParametersDefinitionProperty paramsDef = new ParametersDefinitionProperty(paramDef);
p.addProperty(paramsDef);
// Build step should succeed when this parameter expands to a job accessible to
// authenticated users, even when selecting a single maven module, not the parent job:
FreeStyleBuild b = p.scheduleBuild2(0, new UserCause(),
new ParametersAction(new StringParameterValue("FOO", "$moduleA"))).get();
String dir = "org.jvnet.hudson.main.test.multimod/";
assertFile(true, dir + "moduleA/1.0-SNAPSHOT/moduleA-1.0-SNAPSHOT.jar", b);
assertFile(true, dir + pomName("moduleA", "1.0-SNAPSHOT"), b);
assertFile(false, dir + "moduleB/1.0-SNAPSHOT/moduleB-1.0-SNAPSHOT.jar", b);
assertFile(false, dir + pomName("moduleB", "1.0-SNAPSHOT"), b);
rule.assertBuildStatusSuccess(b);
}
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:27,代码来源:CopyArtifactTest.java
示例3: cd
import hudson.util.VersionNumber; //导入依赖的package包/类
@Issue("JENKINS-33510")
@Test public void cd() throws Exception {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
DockerTestUtil.assumeDocker(new VersionNumber("17.12"));
WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "prj");
p.setDefinition(new CpsFlowDefinition(
"node {\n" +
" withDockerContainer('ubuntu') {\n" +
" sh 'mkdir subdir && echo somecontent > subdir/file'\n" +
" dir('subdir') {\n" +
" sh 'pwd; tr \"a-z\" \"A-Z\" < file'\n" +
" }\n" +
" }\n" +
"}", true));
WorkflowRun b = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
story.j.assertLogContains("SOMECONTENT", b);
}
});
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:21,代码来源:WithContainerStepTest.java
示例4: suffersFromJENKINS24358
import hudson.util.VersionNumber; //导入依赖的package包/类
private static boolean suffersFromJENKINS24358() {
VersionNumber version = Jenkins.getVersion();
if (version == null) {
return false;
} else if (version.compareTo(/*JENKINS-19544*/new VersionNumber("1.557")) >=0 && version.compareTo(new VersionNumber(/*JENKINS-24358*/"1.578")) < 0) {
if (version.toString().startsWith("1.565.") && version.compareTo(new VersionNumber(/* predicting JENKINS-24358 to be backported here */"1.565.3")) >=0) {
return false;
} else {
return true;
}
} else if (version.toString().startsWith(/* JENKINS-19544 backported to 1.554.1 */"1.554.")) {
return true;
} else { // before regression or after fix
return false;
}
}
开发者ID:jenkinsci,项目名称:support-core-plugin,代码行数:17,代码来源:AdministrativeMonitors.java
示例5: version
import hudson.util.VersionNumber; //导入依赖的package包/类
/**
* Get the docker version.
*
* @return The {@link VersionNumber} instance if the version string matches the expected format,
* otherwise {@code null}.
*/
public @CheckForNull VersionNumber version() throws IOException, InterruptedException {
LaunchResult result = launch(new EnvVars(), true, "-v");
if (result.getStatus() == 0) {
return parseVersionNumber(result.getOut());
} else {
return null;
}
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:15,代码来源:DockerClient.java
示例6: parseVersionNumber
import hudson.util.VersionNumber; //导入依赖的package包/类
/**
* Parse a Docker version string (e.g. "Docker version 1.5.0, build a8a31ef").
* @param versionString The version string to parse.
* @return The {@link VersionNumber} instance if the version string matched the
* expected format, otherwise {@code null}.
*/
protected static VersionNumber parseVersionNumber(@Nonnull String versionString) {
Matcher matcher = pattern.matcher(versionString.trim());
if (matcher.matches()) {
String major = matcher.group(2);
String minor = matcher.group(3);
String maint = matcher.group(4);
return new VersionNumber(String.format("%s.%s.%s", major, minor, maint));
} else {
return null;
}
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:18,代码来源:DockerClient.java
示例7: Decorator
import hudson.util.VersionNumber; //导入依赖的package包/类
Decorator(String container, EnvVars envHost, String ws, String toolName, VersionNumber dockerVersion) {
this.container = container;
this.envHost = Util.mapToEnv(envHost);
this.ws = ws;
this.toolName = toolName;
this.hasEnv = dockerVersion != null && dockerVersion.compareTo(new VersionNumber("1.13.0")) >= 0;
this.hasWorkdir = dockerVersion != null && dockerVersion.compareTo(new VersionNumber("17.12")) >= 0;
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:9,代码来源:WithContainerStep.java
示例8: buildWithMultiStage
import hudson.util.VersionNumber; //导入依赖的package包/类
@Test public void buildWithMultiStage() {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
assumeDocker(new VersionNumber("17.05"));
WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "prj");
p.setDefinition(new CpsFlowDefinition(
"node {\n" +
" sh 'mkdir -p child'\n" +
" writeFile file: 'child/stuff1', text: 'hello'\n" +
" writeFile file: 'child/stuff2', text: 'world'\n" +
" writeFile file: 'child/stuff3', text: env.BUILD_NUMBER\n" +
" writeFile file: 'child/Dockerfile.other', " +
"text: '# This is a test.\\n" +
"\\n" +
"FROM hello-world AS one\\n" +
"ARG stuff4=4\\n" +
"ARG stuff5=5\\n" +
"COPY stuff1 /\\n" +
"FROM scratch\\n" +
"COPY --from=one /stuff1 /\\n" +
"COPY stuff2 /\\nCOPY stuff3 /\\n'\n" +
" def built = docker.build 'hello-world-stuff-arguments', '-f child/Dockerfile.other --build-arg stuff4=build4 --build-arg stuff5=build5 child'\n" +
" echo \"built ${built.id}\"\n" +
"}", true));
// Note the absence '--pull' in the above docker build ags as compared to other tests.
// This is due to a Docker bug: https://github.com/docker/for-mac/issues/1751
// It can be re-added when that is fixed
WorkflowRun b = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
DockerClient client = new DockerClient(new Launcher.LocalLauncher(StreamTaskListener.NULL), null, null);
String descendantImageId1 = client.inspect(new EnvVars(), "hello-world-stuff-arguments", ".Id");
story.j.assertLogContains("built hello-world-stuff-arguments", b);
story.j.assertLogNotContains(" --no-cache ", b);
story.j.assertLogContains(descendantImageId1.replaceFirst("^sha256:", "").substring(0, 12), b);
story.j.assertLogContains(" --build-arg stuff4=build4 ", b);
story.j.assertLogContains(" --build-arg stuff5=build5 ", b);
}
});
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:41,代码来源:DockerDSLTest.java
示例9: assumeDocker
import hudson.util.VersionNumber; //导入依赖的package包/类
public static void assumeDocker(VersionNumber minimumVersion) throws Exception {
Launcher.LocalLauncher localLauncher = new Launcher.LocalLauncher(StreamTaskListener.NULL);
try {
Assume.assumeThat("Docker working", localLauncher.launch().cmds(DockerTool.getExecutable(null, null, null, null), "ps").start().joinWithTimeout(DockerClient.CLIENT_TIMEOUT, TimeUnit.SECONDS, localLauncher.getListener()), is(0));
} catch (IOException x) {
Assume.assumeNoException("have Docker installed", x);
}
DockerClient dockerClient = new DockerClient(localLauncher, null, null);
Assume.assumeFalse("Docker version not < " + minimumVersion.toString(), dockerClient.version().isOlderThan(minimumVersion));
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:11,代码来源:DockerTestUtil.java
示例10: test_valid_version
import hudson.util.VersionNumber; //导入依赖的package包/类
@Test
public void test_valid_version() {
VersionNumber dockerVersion = DockerClient.parseVersionNumber("Docker version 1.5.0, build a8a31ef");
Assert.assertFalse(dockerVersion.isOlderThan(new VersionNumber("1.1")));
Assert.assertFalse(dockerVersion.isOlderThan(new VersionNumber("1.5")));
Assert.assertTrue(dockerVersion.isOlderThan(new VersionNumber("1.10")));
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:8,代码来源:DockerClientTest.java
示例11: parseVersion
import hudson.util.VersionNumber; //导入依赖的package包/类
private static VersionNumber parseVersion(String version) {
// any version that sorts before 17.05.0-ce
if (version.equals("latest")) return new VersionNumber("0");
final Matcher matcher = Pattern.compile("(\\d+\\.\\d+\\.\\d+).*").matcher(version);
if (matcher.matches()) return new VersionNumber(matcher.group(1));
throw new IllegalArgumentException("Failed to parse version " + version);
}
开发者ID:jenkinsci,项目名称:docker-commons-plugin,代码行数:10,代码来源:DockerToolInstaller.java
示例12: getBuildNumber
import hudson.util.VersionNumber; //导入依赖的package包/类
/**
* Retrieves the build number of this CloudTest server.
* Postcondition: The build number returned is never null.
*/
public VersionNumber getBuildNumber() throws IOException {
if (url == null) {
// User didn't enter a value in the Configure Jenkins page.
// Nothing we can do.
throw new IllegalStateException("No URL has been configured for this CloudTest server.");
}
GenericSelfClosingHttpClient client = createClient();
HttpGet get = new HttpGet(url);
String responseBody = client.sendRequest(get);
Document doc = Jsoup.parse(responseBody);
Elements elements = doc.select("meta[name=buildnumber]");
if (elements != null && elements.size() >= 1)
{
String buildNumber = elements.get(0).attr("content");
if (buildNumber != null)
{
return new VersionNumber(buildNumber);
}
}
throw new Error("failed to find build number");
}
开发者ID:jenkinsci,项目名称:cloudtest-plugin,代码行数:32,代码来源:CloudTestServer.java
示例13: isInstalled
import hudson.util.VersionNumber; //导入依赖的package包/类
public boolean isInstalled() {
if (installedVersion == null) {
return false;
}
try {
PluginWrapper pluginWrapper = Jenkins.getInstance().getPluginManager().getPlugin(getClass());
String targetVersion = getVersionString(pluginWrapper);
LOGGER.log(Level.FINE, "Installed version = {0}. Target version = {1}",
new Object[]{installedVersion, targetVersion});
return !new VersionNumber(installedVersion).isOlderThan(new VersionNumber(targetVersion));
} catch (Throwable t) {
// if in doubt, it's not installed
return false;
}
}
开发者ID:jenkinsci,项目名称:cloudbees-enterprise-plugins-plugin,代码行数:16,代码来源:PluginImpl.java
示例14: start
import hudson.util.VersionNumber; //导入依赖的package包/类
@Override public boolean start() throws Exception {
EnvVars envReduced = new EnvVars(env);
EnvVars envHost = computer.getEnvironment();
envReduced.entrySet().removeAll(envHost.entrySet());
// Remove PATH during cat.
envReduced.remove("PATH");
envReduced.remove("");
LOGGER.log(Level.FINE, "reduced environment: {0}", envReduced);
workspace.mkdirs(); // otherwise it may be owned by root when created for -v
String ws = workspace.getRemote();
toolName = step.toolName;
DockerClient dockerClient = new DockerClient(launcher, node, toolName);
VersionNumber dockerVersion = dockerClient.version();
if (dockerVersion != null) {
if (dockerVersion.isOlderThan(new VersionNumber("1.7"))) {
throw new AbortException("The docker version is less than v1.7. Pipeline functions requiring 'docker exec' (e.g. 'docker.inside') or SELinux labeling will not work.");
} else if (dockerVersion.isOlderThan(new VersionNumber("1.8"))) {
listener.error("The docker version is less than v1.8. Running a 'docker.inside' from inside a container will not work.");
}
} else {
listener.error("Failed to parse docker version. Please note there is a minimum docker version requirement of v1.7.");
}
FilePath tempDir = tempDir(workspace);
tempDir.mkdirs();
String tmp = tempDir.getRemote();
Map<String, String> volumes = new LinkedHashMap<String, String>();
Collection<String> volumesFromContainers = new LinkedHashSet<String>();
Optional<String> containerId = dockerClient.getContainerIdIfContainerized();
if (containerId.isPresent()) {
listener.getLogger().println(node.getDisplayName() + " seems to be running inside container " + containerId.get());
final Collection<String> mountedVolumes = dockerClient.getVolumes(env, containerId.get());
final String[] dirs = {ws, tmp};
for (String dir : dirs) {
// check if there is any volume which contains the directory
boolean found = false;
for (String vol : mountedVolumes) {
if (dir.startsWith(vol)) {
volumesFromContainers.add(containerId.get());
found = true;
break;
}
}
if (!found) {
listener.getLogger().println("but " + dir + " could not be found among " + mountedVolumes);
volumes.put(dir, dir);
}
}
} else {
listener.getLogger().println(node.getDisplayName() + " does not seem to be running inside a container");
volumes.put(ws, ws);
volumes.put(tmp, tmp);
}
container = dockerClient.run(env, step.image, step.args, ws, volumes, volumesFromContainers, envReduced, dockerClient.whoAmI(), /* expected to hang until killed */ "cat");
DockerFingerprints.addRunFacet(dockerClient.getContainerRecord(env, container), run);
ImageAction.add(step.image, run);
getContext().newBodyInvoker().
withContext(BodyInvoker.mergeLauncherDecorators(getContext().get(LauncherDecorator.class), new Decorator(container, envHost, ws, toolName, dockerVersion))).
withCallback(new Callback(container, toolName)).
start();
return false;
}
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:68,代码来源:WithContainerStep.java
示例15: isNewJenkins
import hudson.util.VersionNumber; //导入依赖的package包/类
public boolean isNewJenkins() {
final VersionNumber matrixBreakOutVersion = new VersionNumber("1.560");
return Jenkins.getVersion().isNewerThan(matrixBreakOutVersion);
}
开发者ID:groupon,项目名称:DotCi,代码行数:5,代码来源:DynamicBuild.java
示例16: CommonInstaller
import hudson.util.VersionNumber; //导入依赖的package包/类
private CommonInstaller(CloudTestServer server, Installers installerType, VersionNumber buildNumber) {
super(installerType.getCTInstallerType()+buildNumber);
this.server = server;
this.installerType = installerType;
this.buildNumber = buildNumber;
}
开发者ID:jenkinsci,项目名称:cloudtest-plugin,代码行数:7,代码来源:CommonInstaller.java
示例17: getBuildNumber
import hudson.util.VersionNumber; //导入依赖的package包/类
VersionNumber getBuildNumber() {
return buildNumber;
}
开发者ID:jenkinsci,项目名称:cloudtest-plugin,代码行数:4,代码来源:CommonInstaller.java
示例18: testBuildNumber
import hudson.util.VersionNumber; //导入依赖的package包/类
public void testBuildNumber() throws IOException {
VersionNumber b = aServer.getBuildNumber();
System.out.println(b);
assertTrue(b.compareTo(new VersionNumber("5"))>=0);
}
开发者ID:jenkinsci,项目名称:cloudtest-plugin,代码行数:6,代码来源:CloudTestServerTest.java
示例19: Dependency
import hudson.util.VersionNumber; //导入依赖的package包/类
private Dependency(String name, String version, boolean optional, boolean mandatory) {
this.name = name;
this.version = version == null ? null : new VersionNumber(version);
this.optional = optional;
this.mandatory = mandatory;
}
开发者ID:jenkinsci,项目名称:cloudbees-enterprise-plugins-plugin,代码行数:7,代码来源:PluginImpl.java
示例20: VersionInfo
import hudson.util.VersionNumber; //导入依赖的package包/类
public VersionInfo(String version, ArtifactRepository repository) {
this.version = new VersionNumber(version);
this.repository = repository;
}
开发者ID:cloudbees,项目名称:bees-maven-components,代码行数:5,代码来源:VersionResolverImpl.java
注:本文中的hudson.util.VersionNumber类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论