Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-70009

Job-Dsl in JCasc needs to evaluate url userInfo

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • job-dsl-plugin
    • None

      JCasC allows to configure jobs through a url:

      jobs:
        - url: https://example.acme.org/job-dsl/testjob.groovy

      We need to add credentials here for basic auth:

      https://myid:mypw@example.acme.org/job-dsl/testjob.groovy

      The way that this is handled in Java & https://github.com/jenkinsci/job-dsl-plugin/blob/master/job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/casc/FromUrlScriptSource.java#L23

      ignores the userInfo. I suggest to replace that line with

      URL realurl = new URL(url);
      URLConnection con = realurl.openConnection();
      if (realurl.getUserInfo() != null) {
          String basicAuth = "Basic " + new String(new Base64().getEncoder().encode(realurl.getUserInfo().getBytes()));
          con.setRequestProperty("Authorization", basicAuth);
      }

      return IOUtils.toString(con.getInputStream());

      I know this straddles the line between feature and bug, but it is a blocker for us. I am also willing to issue a pull request.

            jamietanna Jamie Tanna
            jungmi Michael Jung
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: