Skip to content
Permalink
Browse files

[JENKINS-26107] Update documentation, examples, and tests to work wit…

…h a blocky stage.
  • Loading branch information...
jglick committed May 12, 2016
1 parent 3868a97 commit a689f3d73d6fc8dcfbe2de270ea37b3f7f68e1b4
@@ -46,31 +46,25 @@ samples.push({
name: 'hello',
title: 'Hello World',
script: "node {\n" +
" stage 'Stage 1'\n" +
" echo 'Hello World 1'\n" +
" stage 'Stage 2'\n" +
" echo 'Hello World 2'\n" +
" echo 'Hello World'\n" +
"}"
});

samples.push({
name: 'github-maven',
title: 'GitHub + Maven',
script: "node {\n" +
" // Mark the code checkout 'stage'....\n" +
" stage 'Checkout'\n" +
"\n" +
" // Get some code from a GitHub repository\n" +
" git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'\n" +
"\n" +
" // Get the maven tool.\n" +
" // ** NOTE: This 'M3' maven tool must be configured\n" +
" // ** in the global configuration. \n" +
" def mvnHome = tool 'M3'\n" +
"\n" +
" // Mark the code build 'stage'....\n" +
" stage 'Build'\n" +
" // Run the maven build\n" +
" sh \"${mvnHome}/bin/mvn clean install\"\n" +
" stage('Preparation') { // for display purposes\n" +
" // Get some code from a GitHub repository\n" +
" git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'\n" +
" // Get the maven tool.\n" +
" // ** NOTE: This 'M3' maven tool must be configured\n" +
" // ** in the global configuration. \n" +
" def mvnHome = tool 'M3'\n" +
" }\n" +
" stage('Build') {\n" +
" // Run the maven build\n" +
" sh \"${mvnHome}/bin/mvn clean install\"\n" +
" }\n" +
"}"
});
@@ -14,15 +14,15 @@
Use the <b>Snippet Generator</b> to see them all and see how they should be configured.
Step parameters are given as key-value pairs; if there is just one mandatory parameter the name may be omitted, so
</p>
<pre>stage 'Build'</pre>
<pre>readFile 'build.properties'</pre>
<p>
is a shortcut for
</p>
<pre>stage name: 'Build'</pre>
<pre>readFile file: 'build.properties'</pre>
<p>
but if you specify multiple parameters they must all be named:
</p>
<pre>stage name: 'Build', concurrency: 1</pre>
<pre>readFile file: 'build.properties', encoding: 'ISO-8859-1'</pre>
<p>
There are also some predefined variables.
Use the <b>Snippet Generator</b> to see them all with usage information.
@@ -62,35 +62,24 @@ snippet for++\n\
for (int ${1:i} = 0; $1 < ${2:Things}.length; $1++) {\n\
${3:$2[$1]}$0\n\
}\n\
# stage\n\
snippet stage\n\
stage '${1}'\n\
# node\n\
snippet node\n\
node {\n\
${1}\n\
}\n\
# node-l ('label') \n\
snippet node-l\n\
node ('${1}') {\n\
\n\
}\n\
";

// TODO: Would be nice to get this from the backend via an AJAX call.
// With each step contributing 1 or more snippets of code
var workflowSnippets =
"# stage\n\
snippet stage\n\
stage '${1}'\n\
stage('${1}')\n\
${2}\n\
}\n\
# node\n\
snippet node\n\
node {\n\
${1}\n\
}\n\
# node-l ('label') \n\
snippet node-l\n\
node ('${1}') {\n\
node('${1}') {\n\
\n\
}\n\
# echo \n\
@@ -113,7 +102,7 @@ snippet fileExists (in workspace)\n\
fileExists('${1}')\n\
# dir (subDir) \n\
snippet dir (subDir)\n\
dir ('${1}') {\n\
dir('${1}') {\n\
${2}\n\
}\n\
# pwd \n\
@@ -124,12 +113,12 @@ snippet deleteDir\n\
deleteDir()\n\
# deleteDir (subDir) \n\
snippet deleteDir (subDir)\n\
dir ('${1}') {\n\
dir('${1}') {\n\
deleteDir()\n\
}\n\
# retry (count) \n\
snippet retry (count)\n\
retry (${1:2}) {\n\
retry(${1:2}) {\n\
\n\
}\n\
# sleep \n\
@@ -54,10 +54,10 @@
import org.jenkinsci.plugins.workflow.steps.CoreStep;
import org.jenkinsci.plugins.workflow.steps.EchoStep;
import org.jenkinsci.plugins.workflow.steps.PwdStep;
import org.jenkinsci.plugins.workflow.steps.ReadFileStep;
import org.jenkinsci.plugins.workflow.steps.Step;
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
import org.jenkinsci.plugins.workflow.support.steps.ExecutorStep;
import org.jenkinsci.plugins.workflow.support.steps.StageStep;
import org.jenkinsci.plugins.workflow.support.steps.WorkspaceStep;
import org.jenkinsci.plugins.workflow.support.steps.build.BuildTriggerStep;
import org.jenkinsci.plugins.workflow.support.steps.input.InputStep;
@@ -84,10 +84,10 @@

@Test public void basics() throws Exception {
assertRoundTrip(new EchoStep("hello world"), "echo 'hello world'");
StageStep s = new StageStep("Build");
assertRoundTrip(s, "stage 'Build'");
s.concurrency = 1;
assertRoundTrip(s, "stage concurrency: 1, name: 'Build'");
ReadFileStep s = new ReadFileStep("build.properties");
assertRoundTrip(s, "readFile 'build.properties'");
s.setEncoding("ISO-8859-1");
assertRoundTrip(s, "readFile encoding: 'ISO-8859-1', file: 'build.properties'");
}

@Email("https://groups.google.com/forum/#!topicsearchin/jenkinsci-users/workflow/jenkinsci-users/DJ15tkEQPw0")

0 comments on commit a689f3d

Please sign in to comment.
You can’t perform that action at this time.