Skip to content
Permalink
Browse files
[JENKINS-38114] Consolidated help for RunWrapper.
  • Loading branch information
jglick committed Sep 22, 2016
1 parent 32c98db commit f7206f4348a3b57abab16943648039920d0e3307
14 pom.xml
@@ -28,8 +28,8 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.14</version>
<relativePath />
<version>2.15</version>
<relativePath/>
</parent>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
@@ -52,13 +52,13 @@
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<properties>
@@ -70,17 +70,17 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.4-SNAPSHOT</version> <!-- TODO https://github.com/jenkinsci/workflow-step-api-plugin/pull/8 -->
<version>2.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>workflow-api</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.1</version>
<version>2.6-SNAPSHOT</version> <!-- TODO https://github.com/jenkinsci/workflow-support-plugin/pull/13 -->
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
@@ -0,0 +1,13 @@
p(raw('''
The <code>currentBuild</code> variable may be used to refer to the currently running build.
It has the following readable properties:
'''))
raw(org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper.class.getResource("RunWrapper/help.html").text)
p(raw('''
Additionally, for this build only (but not for other builds), the following properties are writable:
'''))
ul {
li {code {b('result')}}
li {code {b('displayName')}}
li {code {b('description')}}
}

This file was deleted.

@@ -33,18 +33,20 @@

import hudson.security.WhoAmI;
import hudson.util.OneShotEvent;
import org.apache.commons.io.FileUtils;
import java.io.IOException;
import java.io.StringWriter;
import static org.hamcrest.Matchers.containsString;
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval;
import org.jenkinsci.plugins.workflow.actions.LogAction;
import org.jenkinsci.plugins.workflow.cps.AbstractCpsFlowTest;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution;
import org.jenkinsci.plugins.workflow.graph.AtomNode;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.jenkinsci.plugins.workflow.steps.RetryStep;
import org.jenkinsci.plugins.workflow.support.actions.LogActionImpl;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
@@ -91,9 +93,15 @@ public void shellStep() throws Exception {
// currentHeads[0] is FlowEndNode, whose parent is BlockEndNode for "node",
// whose parent is BlockEndNode for body invocation, whose parent is AtomNode
AtomNode atom = (AtomNode) e.getCurrentHeads().get(0).getParents().get(0).getParents().get(0).getParents().get(0);
LogActionImpl la = (LogActionImpl) atom.getAction(LogAction.class);
String text = FileUtils.readFileToString(la.getLogFile());
assertTrue(text, text.contains("hello world"));
assertThat(logOf(atom), containsString("hello world"));
}

private String logOf(FlowNode node) throws IOException {
LogAction la = node.getAction(LogAction.class);
assertNotNull(la);
StringWriter w = new StringWriter();
la.getLogText().writeLogTo(0, w);
return w.toString();
}

/**
@@ -187,9 +195,7 @@ public void sandbox() throws Exception {
// currentHeads[0] is FlowEndNode, whose parent is BlockEndNode for "node",
// whose parent is BlockEndNode for body invocation, whose parent is AtomNode
AtomNode atom = (AtomNode) b.getExecution().getCurrentHeads().get(0).getParents().get(0).getParents().get(0).getParents().get(0);
LogActionImpl la = (LogActionImpl) atom.getAction(LogAction.class);
String text = FileUtils.readFileToString(la.getLogFile());
assertTrue(text, text.contains("hello world"));
assertThat(logOf(atom), containsString("hello world"));
}

/**
@@ -240,11 +240,12 @@ public class SnippetizerTest {
assertThat("content is written to the end", html, containsString("</body></html>"));
}

@Issue("JENKINS-35395")
@Issue({"JENKINS-35395", "JENKINS-38114"})
@Test public void doGlobalsRef() throws Exception {
JenkinsRule.WebClient wc = r.createWebClient();
String html = wc.goTo(Snippetizer.ACTION_URL + "/globals").getWebResponse().getContentAsString();
assertThat("text from RunWrapperBinder/help.jelly is included", html, containsString("may be used to refer to the currently running build"));
assertThat("text from RunWrapperBinder/help.jelly includes text from RunWrapper/help.html", html, containsString("<dt><code>buildVariables</code></dt>"));
assertThat("content is written to the end", html, containsString("</body></html>"));
}

0 comments on commit f7206f4

Please sign in to comment.