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

Added docs and js example for REST API usage #104

Merged
merged 8 commits into from
May 18, 2022
Merged
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
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ You can use Base64 parameters for passing _small_ files to downstream builds:
build job: 'downstream', parameters: [base64File(name: 'file', base64: Base64.encoder.encodeToString('hello'.bytes)))]
```

## Usage with HTTP API

You can pass file parameters to the HTTP API (in the Jenkins UI, this HTTP API is also referred to as “REST API”):

Curl example:

```bash
curl -u $auth -F FILE=@/tmp/f $jenkins/job/myjob/buildWithParameters
```

Javascript example:

```js
const file = fileInput.files[0]; // a File object
const body = new FormData();
body.append('FILE', file); // will come through to the job as the named file parameter 'FILE'
const request = new Request(`${jobUrl}buildWithParameters`, { method: 'POST', body });
fetch(request); // omitted, API token and other credentials
```

## LICENSE

Licensed under MIT, see [LICENSE](LICENSE.md)