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

Add a withGit pipeline step that provides git credentials

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Duplicate
    • Component/s: git-plugin
    • Labels:
      None
    • Similar Issues:

      Description

      It would be nice if we had a withGit step that would pre-configure the git credentials from the current "scm" object and allows us to invoke git from the command line as follows:

      withGit {
         sh 'git fetch'
      }

      The step would rely on the same GIT_ASKPASS mechanism as used during a "standard" checkout.

       

        Attachments

        1. mktemp.groovy
          0.6 kB
        2. rmdir.groovy
          0.4 kB
        3. utils.groovy
          2 kB
        4. withGit.groovy
          3 kB

          Issue Links

            Activity

            Hide
            sneko Thomas Ramé added a comment -

            Bertrand Renuart I checked online the docs for Jenkins Pipeline and have found that I was able to replace your line:

                        if (utils.isUnixLike()) {
            

            by

                        if (isUnix()) {
            

            I'm still looking for an official way to delete the directory with an official manner since your "rmdir" is apparently also imported from your shared library ("No such DSL method 'rmdir' found among steps")

            Show
            sneko Thomas Ramé added a comment - Bertrand Renuart I checked online the docs for Jenkins Pipeline and have found that I was able to replace your line: if (utils.isUnixLike()) { by if (isUnix()) { I'm still looking for an official way to delete the directory with an official manner since your "rmdir" is apparently also imported from your shared library ("No such DSL method 'rmdir' found among steps")
            Hide
            brenuart Bertrand Renuart added a comment -

            Additional files... If you are still missing stuff, email me and I'll send you a zip with everything... (don't want to use Jira here as a file exchange mechanism

            Show
            brenuart Bertrand Renuart added a comment - Additional files... If you are still missing stuff, email me and I'll send you a zip with everything... (don't want to use Jira here as a file exchange mechanism
            Hide
            sneko Thomas Ramé added a comment -

            It works like a charm! You made me saving time  ... Thank you!

             

            For anyone who is interested, don't hesitate to fork the following repo (I have wrapped required files into a library ready to be used in Jenkins):

            https://github.com/sneko/jenkins-git-shared

             

            Show
            sneko Thomas Ramé added a comment - It works like a charm! You made me saving time  ... Thank you!   For anyone who is interested, don't hesitate to fork the following repo (I have wrapped required files into a library ready to be used in Jenkins): https://github.com/sneko/jenkins-git-shared  
            Hide
            solvingj jerry wiltse added a comment -

            we created one also.
            damn i wish this existed to work around:
            https://issues.jenkins.io/browse/JENKINS-30600

            Show
            solvingj jerry wiltse added a comment - we created one also. damn i wish this existed to work around: https://issues.jenkins.io/browse/JENKINS-30600
            Hide
            markewaite Mark Waite added a comment -

            Closing as a duplicate of JENKINS-28335. Refer to the Google Summer of Code project idea proposing how JENKINS-28335 should be implemented.

            The project idea needs additional mentors and welcomes additional insights on corner cases that might not be covered by the proposed implementation.

            Show
            markewaite Mark Waite added a comment - Closing as a duplicate of JENKINS-28335 . Refer to the Google Summer of Code project idea proposing how JENKINS-28335 should be implemented. The project idea needs additional mentors and welcomes additional insights on corner cases that might not be covered by the proposed implementation.

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              brenuart Bertrand Renuart
              Votes:
              8 Vote for this issue
              Watchers:
              10 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: