Skip to content

Commit

Permalink
Merge pull request #69 from jglick/RunWrapper-help-JENKINS-38114
Browse files Browse the repository at this point in the history
[JENKINS-38114] Consolidated help for RunWrapper
  • Loading branch information
jglick committed Sep 23, 2016
2 parents d40b3dd + c7c6ab4 commit 3f34369
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 31 deletions.
16 changes: 8 additions & 8 deletions pom.xml
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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</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</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down Expand Up @@ -130,7 +130,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.7-SNAPSHOT</version>
<version>2.7</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
@@ -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.

Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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"));
}

/**
Expand Down
Expand Up @@ -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>"));
}

Expand Down

0 comments on commit 3f34369

Please sign in to comment.