I am trying to push some tags back to repository and for obvious reasons, i 
would like to keep my usernam/pass hidden. I use withcredentials for this 
and the code looks like this:

checkout([$class: 'GitSCM', branches: [[name: '*/master']], 
doGenerateSubmoduleConfigurations: false, extensions: [[$class: 
'RelativeTargetDirectory', relativeTargetDir: 'git']], submoduleCfg: [], 
userRemoteConfigs: [[url: 'http://my-GITBUCKET-gitURL.git']]])

        
dir ('git') {

withCredentials([usernamePassword(credentialsId: 
'11111111-1111-11111-11111-111111122222', usernameVariable: 'GIT_USERNAME', 
passwordVariable: 'GIT_PASSWORD')]) {
sh "git credential approve"
sh 'git tag -a ' + env.BUILD_ID + ' -m "Creating tag"'
sh "git push origin " + env.BUILD_ID
}
}

This always gives me the following error:

09:45:12 [git] Running shell script
09:45:13 + git push origin 124
09:45:13 fatal: could not read Username for 
'http://my-GITBUCKET-gitURL.git': No such device or address

I tried learning more about this error and seems like it should have been 
working after using GIT approve, but apparently it is not.

I tried something like below and *it works fine, only that it is an ugly 
workaround* and i do not with to use as a final solution.

checkout([$class: 'GitSCM', branches: [[name: '*/master']], 
doGenerateSubmoduleConfigurations: false, extensions: [[$class: 
'RelativeTargetDirectory', relativeTargetDir: 'git']], submoduleCfg: [], 
userRemoteConfigs: [[url: 'http://my-GITBUCKET-gitURL.git']]])

        
dir ('git') {

withCredentials([usernamePassword(credentialsId: 
'11111111-1111-11111-11111-111111122222', usernameVariable: 'GIT_USERNAME', 
passwordVariable: 'GIT_PASSWORD')]) {
sh "git credential approve"
sh 'git tag -a ' + env.BUILD_ID + ' -m "Creating tag"'
sh "git push http://${GIT_USERNAME}:${GIT_PASSWORD}@${repoURL.substring(7)} 
--tags"
}
}


-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/f0c29762-0ab2-48c9-a15a-74a6407f81fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to