Generally when you do a basic checkout, the Jenkins workspace is in a 
detached HEAD state. You want to check out to a local branch likely using "
localBranch". I have to ask though - if Jenkins does a merge of the PR - 
why would you need to push?

On Friday, March 24, 2017 at 7:37:57 AM UTC-4, Idan Adar wrote:
>
> How do you get "git push" to work in a Jenkinsfile? I am not sure what am 
> I missing.
>
> The Jenkinsfile checkouts a repo using an access token (this is configured 
> in the Jenkins UI for the job).
> The Jenkins file also does a merge of a PR in one of its stages: 
>
> withCredentials([usernamePassword(credentialsId: '****', usernameVariable: 
> 'ACCESS_TOKEN_USERNAME', passwordVariable: 'ACCESS_TOKEN_PASSWORD',)]) {
>     sh "curl -X PUT -d '{\"commit_title\": \"Merge pull request\"}' 
>  https://***/pulls/$CHANGE_ID/merge?access_token=$ACCESS_TOKEN_PASSWORD";
> }
>
> But I can't get "git push" to work in another stage:
>
> git config --global user.name '****'
> git config --global user.email ****
> git commit -am 'Bumped version number'
> git remote set-url origin git@****.git
> git push origin master
>
> I tried wrapping the above in withCredential and also . with agent, but 
> nothing works...  
>
> Tips?
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/a26230a4-0d7f-4562-8012-d10c35973739%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to