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

Since 2.2.6, environment variables are not expanded in git publisher

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: git-plugin
    • Labels:
    • Environment:
      Jenkins: 1.580
      Git Plugin 2.2.6 (before update 2.2.5)
      All plugins up to date (21. September)
    • Similar Issues:

      Description

      Since 2.2.6 ssh credentials on git push seems to have a problem.
      When i revert back to 2.2.5 everything works as expected.
      I'm using jenkins credential with a ssh key.
      Don't know if that has something to say, but I'm using env var's to set the git url, and in the failing log it's not resolved. But I guess the error prints it before the resolution, because the connection itself seems to work, just not the authentication.
      I attached a log success.txt (with version 2.2.5) and a failing.txt (version 2.2.6). The only difference is that i reverted the plugin to 2.2.5 and everything worked again.
      let me know if you need more information. But maybe so find the problem due the recent changes.

        Attachments

        1. config.xml
          3 kB
        2. config.xml
          5 kB
        3. failing.txt
          5 kB
        4. success.txt
          4 kB

          Issue Links

            Activity

            Hide
            goddi Daniel Figus added a comment -

            Hi Mark,

            I also ran into the issue and had a look into the code. I try to summarize what I already found out - I hope this helps:

            As the fetch is working I focused on analyzing the differences between the fetch and the push. As far as I understood the code the GitSCM holds the remote repository without expanded environment variables and expands them right before the fetch (https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitSCM.java#L915). This step is is missing in the GitPublisher where the specified remote repository is retrieved from the gitSCM (https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitPublisher.java#L318). As this issue is urgent for our production I already started to prepare a test and fix for this issue. My naive approach would be simply do the same thing as GitSCM.getParamExpandedRepos() does right where the push command is created and executed. But as you wrote that you hit a wall here I'm a bit unconfident. Could you please share your concerns? I would need some more days to prepare a fix for a pull request but so far my first tests looked promising.

            Show
            goddi Daniel Figus added a comment - Hi Mark, I also ran into the issue and had a look into the code. I try to summarize what I already found out - I hope this helps: As the fetch is working I focused on analyzing the differences between the fetch and the push. As far as I understood the code the GitSCM holds the remote repository without expanded environment variables and expands them right before the fetch ( https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitSCM.java#L915 ). This step is is missing in the GitPublisher where the specified remote repository is retrieved from the gitSCM ( https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitPublisher.java#L318 ). As this issue is urgent for our production I already started to prepare a test and fix for this issue. My naive approach would be simply do the same thing as GitSCM.getParamExpandedRepos() does right where the push command is created and executed. But as you wrote that you hit a wall here I'm a bit unconfident. Could you please share your concerns? I would need some more days to prepare a fix for a pull request but so far my first tests looked promising.
            Hide
            markewaite Mark Waite added a comment -

            Daniel Figus Your approach sounds promising. I hit a wall when I couldn't construct a set of tests which gave me enough confidence that I'd solved the problem without critically damaging something else.

            Since you're a directly involved user, you'll be able to test drive your changes in your own environment. A pull request from you will then allow me and/or Nicolas (or others) to review your changes in depth.

            Show
            markewaite Mark Waite added a comment - Daniel Figus Your approach sounds promising. I hit a wall when I couldn't construct a set of tests which gave me enough confidence that I'd solved the problem without critically damaging something else. Since you're a directly involved user, you'll be able to test drive your changes in your own environment. A pull request from you will then allow me and/or Nicolas (or others) to review your changes in depth.
            Hide
            goddi Daniel Figus added a comment -

            Created pull request 283 containing fix and tests. The updated git-plugin runs in our production jenkins without issues. Could you please review and provide feedback?

            Show
            goddi Daniel Figus added a comment - Created pull request 283 containing fix and tests. The updated git-plugin runs in our production jenkins without issues. Could you please review and provide feedback?
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Daniel Figus
            Path:
            src/main/java/hudson/plugins/git/GitPublisher.java
            src/main/java/hudson/plugins/git/GitSCM.java
            src/test/java/hudson/plugins/git/GitPublisherTest.java
            http://jenkins-ci.org/commit/git-plugin/f841caf3c2483532aad9feb20d2f3fac9722a878
            Log:
            JENKINS-24786 Environment variables are not expanded in git publisher

            Fix: Git publisher fails if remote repository configuration contains
            environment variables

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Figus Path: src/main/java/hudson/plugins/git/GitPublisher.java src/main/java/hudson/plugins/git/GitSCM.java src/test/java/hudson/plugins/git/GitPublisherTest.java http://jenkins-ci.org/commit/git-plugin/f841caf3c2483532aad9feb20d2f3fac9722a878 Log: JENKINS-24786 Environment variables are not expanded in git publisher Fix: Git publisher fails if remote repository configuration contains environment variables
            Hide
            markewaite Mark Waite added a comment -

            The change from Daniel Figus has been rebased into the git plugin main line and will be available in git plugin 2.3.3 and later.

            Show
            markewaite Mark Waite added a comment - The change from Daniel Figus has been rebased into the git plugin main line and will be available in git plugin 2.3.3 and later.

              People

              • Assignee:
                markewaite Mark Waite
                Reporter:
                spali Thomas Spalinger
              • Votes:
                3 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: