Search code examples
shelljenkinssh

commit and push generically with Jenkins in a Freestyle project


I'm trying to commit and push the changes to Bitbucket using a Jenkins Job

The job is a Freestsyle Project with "Execute Shell" as a build step.

What I currently did inside the build step of "Execute Shell" is the following:

python run.py

git config --global user.email "name@gmail.com"
git config --global user.name "name"

git add .
git commit -m 'jenkins.job : update...'

Then I push the changes with Git Publisher.

This works as expected in my local computer but is there a way to retrieve the credentials that I used in Source Code Management with Jenkins variables instead of using git config (because I'm not allowed to use git config error: could not lock config file //.gitconfig: Permission denied)


Solution

  • I fixed it using git -c user.name=".." -c user.email="..@.." commit -m ".."

    This way I can set temporary configuration data.