Skip to content

Commit

Permalink
Merge pull request #47 from jglick/Base64
Browse files Browse the repository at this point in the history
Show that `Base64` can be used in Groovy for simple manipulations
  • Loading branch information
jglick authored May 27, 2021
2 parents 4e54ca3 + 9778897 commit 4659ce1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Nor can you use the `withFileParameter` wrapper here.
You can use Base64 parameters for passing _small_ files to downstream builds:

```groovy
build job: 'downstream', parameters: [base64File(name: 'file', base64: 'aGVsbG8=')]
build job: 'downstream', parameters: [base64File(name: 'file', base64: Base64.encoder.encodeToString('hello'.bytes)))]
```

## LICENSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,16 @@ public class AbstractFileParameterDefinitionTest {
r.assertLogContains("received null: null", b);
}

@Test public void buildStep() throws Exception {
WorkflowJob us = r.createProject(WorkflowJob.class, "us");
us.setDefinition(new CpsFlowDefinition("build job: 'ds', parameters: [base64File(name: 'FILE', base64: Base64.encoder.encodeToString('a message'.bytes))]", true));
WorkflowJob ds = r.createProject(WorkflowJob.class, "ds");
ds.addProperty(new ParametersDefinitionProperty(new Base64FileParameterDefinition("FILE")));
ds.setDefinition(new CpsFlowDefinition("echo(/got ${new String(Base64.decoder.decode(FILE))}/)", true));
r.buildAndAssertSuccess(us);
WorkflowRun b = ds.getBuildByNumber(1);
assertNotNull(b);
r.assertLogContains("got a message", b);
}

}

0 comments on commit 4659ce1

Please sign in to comment.