cliffano / nestor

Jenkins CLI and node.js client
http://blog.cliffano.com/tag/nestor/
MIT License
182 stars 27 forks source link

Job within a folder results in Not Found error #58

Open cliffano opened 2 years ago

cliffano commented 2 years ago

When triggering a build for a job that sits under a folder, e.g.

nestor build abc/job/123 "param1=a&param2=b"

The above results in Not Found error.

The root cause for this scenario is due to "abc/job/123" is being passed to swaggy-jenkins' buildUrl which encodes the value to "abc%2Fjob%2F123"

    function buildUrl(path, pathParams, apiBasePath) {
      var _this = this;

      if (!path.match(/^\//)) {
        path = '/' + path;
      }

      var url = this.basePath + path; // use API (operation, path) base path if defined

      if (apiBasePath !== null && apiBasePath !== undefined) {
        url = apiBasePath + path;
      }

      url = url.replace(/\{([\w-\.]+)\}/g, function (fullMatch, key) {
        var value;

        if (pathParams.hasOwnProperty(key)) {
          value = _this.paramToString(pathParams[key]);
        } else {
          value = fullMatch;
        }

        return encodeURIComponent(value);
      });
      return url;

Tested with nestor 2.2.0

cliffano commented 2 years ago

This is temporarily fixed ad-hoc-ly in swaggy-jenkins 2.0.1 https://github.com/cliffano/swaggy-jenkins/releases/tag/2.0.1 , which is used in nestor 2.2.2.

Keeping this ticket open until I can put in long-term fix in swaggy-jenkins (will require openapi-generator patch).