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

withCredentials is not able to push commits

XMLWordPrintable

      I am using the below syntax to pull and push the code. But the code push is not working as expected and generating the following error message:

      fatal: could not read Username for 'https://bitbucketurl.com': No such device or address 

      a. Code that is not working:

      checkout([$class: 'GitSCM',
      branches: [[name: 'develop']],
      userRemoteConfigs: [[credentialsId: 'devops-srvuser-creds', url: "https://${bitbucketURL}/${repository_project}/${repoName}.git"]]])
      withCredentials([usernamePassword(credentialsId: 'devops-srvuser-creds', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
        sh ''' 
        git checkout develop 
        rm -rf target 
        mvn versions:set -DnextSnapshot=true 
        rm -rf pom.xml.versionsBackup 
        git config user.email 'devops.srvuser@example.com' 
        git config user.name 'Devops SrvUser' 
        git add . 
        git commit -m 'xxxx-420 - Updated the POM version to nextSnapshot version' 
        git push  
        ''' 
      }

       
      b. Code that is working:

      checkout([$class: 'GitSCM', 
      branches: [[name: 'develop']], 
      userRemoteConfigs: [[credentialsId: 'devops-srvuser-creds', url: "https://${bitbucketURL}/${repository_project}/${repoName}.git"]]]) 
      withCredentials([usernamePassword(credentialsId: 'devops-srvuser-creds', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { 
        sh ''' 
        git checkout develop 
        rm -rf target 
        mvn versions:set -DnextSnapshot=true 
        rm -rf pom.xml.versionsBackup 
        git config user.email 'devops.srvuser@example.com' 
        git config user.name 'Devops SrvUser' 
        git add . 
        git commit -m 'xxxx-420 - Updated the POM version to nextSnapshot version' 
        git push "https://$GIT_USERNAME:$GIT_PASSWORD@github.com/scm/dev/automation.git"
        ''' 
      }

       

            Unassigned Unassigned
            udayendu Udayendu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: