Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various text edits for docs #9

Merged
merged 2 commits into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ Offers alternative types of file parameter that are compatible with Pipeline and

See [JENKINS-27413](https://issues.jenkins-ci.org/browse/JENKINS-27413) and [JENKINS-29289](https://issues.jenkins-ci.org/browse/JENKINS-29289) for background.

## Usage in declarative pipeline
## Usage in Declarative Pipeline

You can now declare file parameters as is in declarative pipeline:
You can now declare and use file parameters via Declarative Pipeline syntax:

```groovy
pipeline {
agent any
parameters {
base64File(name: 'FILE')
stashedFile(name: 'FILE-STASH')
base64File(name: 'small')
stashedFile(name: 'large')
}
stages {
stage('Example') {
steps {
withFileParameter(name:'FILE', allowNoFile: true) {
sh 'cat $FILE'
withFileParameter(name: 'small') {
sh 'cat $small'
}
unstash 'FILE-STASH'
echo(/loaded '${readFile('FILE-STASH')}'/)
unstash 'large'
sh 'cat large'
}
}
}
Expand Down Expand Up @@ -84,7 +84,7 @@ pipeline {
- [ ] design
- [ ] manual test
- [ ] automated test
- [ ] tests using Declarative syntax
- [X] tests using Declarative syntax
- [ ] tests using `build-token-root`

## Getting started
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?jelly escape-by-default='true'?>
<div>
TODO
Provides an alternative set of file parameters that work with Pipeline, unlike the type built into Jenkins core.
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
<div>
<p>File parameter compatible with Pipeline, must be used with small files</p>
</div>
<p>
Simple file parameter compatible with Pipeline.
Transmits file contents as an environment variable in Base64 encoding,
so it is best used with fairly small files.
Example usage from Declarative Pipeline:
</p>
<pre>
pipeline {
agent any
parameters {
base64File(name: 'FILE')
}
stages {
stage('Example') {
steps {
sh 'echo $FILE | base64 -d > config.yaml'
}
}
}
}
</pre>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div>
Per default, there will be an error if there is no parameter. You can avoid failure by allowing no file.
By default, an error will be thrown if there is no file uploaded to the build.
With this option, the build will proceed, and the environment variable will simply not be defined.
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</pre>
</div>
<div>
Per default, there will be an error if there is no parameter for the build but you can ignore this error using the
parameter attribute <code>allowNoFile</code>. In this case your pipeline must take into account the file doesn't exists
By default, there will be an error if there is no parameter for the build but you can ignore this error using the
parameter attribute <code>allowNoFile</code>. In this case your Pipeline must take into account the possibility that the file does not exist:
<pre>
pipeline {
agent any
Expand All @@ -35,7 +35,7 @@
stage('Example') {
steps {
withFileParameter(name:'THEFILE', allowNoFile: true) {
echo(/loaded '${readFile(THEFILE)}' from $THEFILE/)
sh 'if [ -f "$THEFILE" ]; then cat $THEFILE; fi'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<div>
<p>File parameter compatible with Pipeline but this one stash the file and must be used to handle bug files, how to use it in a declarative pipeline:</p>
<pre>
<p>
File parameter compatible with Pipeline but using the stash system, better suited to large files.
The file will be saved to a stash named like the parameter containing one entry, also named like the parameter.
Example usage from Declarative Pipeline:
</p>
<pre>
pipeline {
agent any
parameters {
stashedFile(name: 'FILE-STASH')
stashedFile(name: 'assets.zip')
}
stages {
stage('Example') {
steps {
unstash "FILE-STASH"
sh 'cat FILE-STASH'
unstash 'assets.zip'
sh 'unzip assets.zip'
}
}
}
}
</pre>
</div>