diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index a176332..367fc4d 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: - node-version: [14.x, 16.x, 18.x] + node-version: [16.x, 18.x, 20.x] steps: - uses: actions/checkout@v1 diff --git a/lib/job.js b/lib/job.js index d24e469..d6e8604 100644 --- a/lib/job.js +++ b/lib/job.js @@ -51,7 +51,7 @@ class Job { if (form) { for (const [name, value] of Object.entries(data)) { - form.append(key, value); + form.append(name, value); } req.body = form; diff --git a/package.json b/package.json index 0f77965..d640a45 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jenkins", "description": "Jenkins client", - "version": "1.0.1", + "version": "1.0.2", "main": "./lib", "files": [ "./lib" diff --git a/test/jenkins.js b/test/jenkins.js index 548b3f8..8da099f 100644 --- a/test/jenkins.js +++ b/test/jenkins.js @@ -179,6 +179,27 @@ describe("jenkins", function () { await this.jenkins.job.build("test", opts); }); + nit("should work with form data parameters", async function () { + this.jenkins = new Jenkins({ + baseUrl: this.url, + crumbIssuer: helper.config.crumbIssuer, + formData: require("form-data"), + }); + this.jenkins.on("log", debug("jenkins:client")); + + this.nock + .post("/job/test/buildWithParameters", /filename="oneName"/gm) + .reply(201); + + const opts = { + parameters: { + oneName: Buffer.from("oneValue"), + twoName: "twoValue", + }, + }; + await this.jenkins.job.build("test", opts); + }); + nit("should work with a token and parameters", async function () { this.nock .post("/job/test/buildWithParameters?token=secret", {