I want to share my Jenkins Pipeline setup 
<https://gist.github.com/amaksoft/b17408303d69c71498eaa39ea2ee3b01> and my 
solution to publish changes/tags to git repo via SSH (While Git Publish 
Support <https://issues.jenkins-ci.org/browse/JENKINS-28335> is under 
development). Please check it out for more info, any improvement ideas are 

In short you just add file *git_push_ssh.groovy* to your project and call 
method pushSSH() from Jenkinsfile like this:

    env.BRANCH_NAME = "mycoolbranch"// BRANCH_NAME is predefined in 
multibranch pipeline job
    env.J_GIT_CONFIG = "true"
    env.J_USERNAME = "Jenkins CI"
    env.J_EMAIL = "jenkins...@example.com"
    env.J_CREDS_IDS = '02aa92ec-593e-4a90-ac85-3f43a06cfae3' // Use 
credentials id from Jenkins
    def gitLib = load "git_push_ssh.groovy"
    gitLib.pushSSH(commitMsg: "Jenkins build #${env.BUILD_NUMBER}", tagName: 
"build-${env.BUILD_NUMBER}", files: "changelog.txt someotherfile.txt");

суббота, 27 августа 2016 г., 4:02:40 UTC+4 пользователь Random Guy написал:
> I tried withCredentials() method...  its giving an error.. 
> NoSuchMethodError...
> java.lang.NoSuchMethodError: No such DSL method 'withCredentials' found
>  Here is how my method look
> withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 
> 'myid', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
>            sh("git tag -a ${TAG_NAME}")
>            sh('git push https://${USERNAME}:${PASSWORD}@game-of-life 
> --tags')
> }
> any idea?
> On Sunday, June 19, 2016 at 8:30:43 AM UTC-7, Mark Waite wrote:
>> I found the answer.  Sorry to bother the list.
>> Git publisher is not yet supported with pipeline (see 
>> https://issues.jenkins-ci.org/browse/JENKINS-28335)
>> A work around to publish to git from a pipeline is available.  See 
>> https://github.com/jenkinsci/pipeline-examples/blob/master/pipeline-examples/push-git-repo/pushGitRepo.Groovy
>> Mark Waite
>> On Sunday, June 19, 2016 at 9:02:10 AM UTC-6, Mark Waite wrote:
>>> I've been creating Jenkins jobs as tests of various bug fixes and 
>>> storing them in a git repository.  Currently, the Jenkins jobs include the 
>>> definition of the verification steps to confirm the bug is fixed.
>>> The pipeline file seems like a better way to check that the problem is 
>>> fixed, since the checks for successful job completion can be done in groovy.
>>> One of the bugs I need to check needs to use the git publisher to push a 
>>> commit back to the originating repository and branch.  In the snippet 
>>> generator I can see an entry for "publishHTML", but I don't see any entry 
>>> that would let me use the git publisher to push changes.  A google search 
>>> also did not show any obvious hints of ways I could use the git publisher.
>>> Are there examples that use the git publisher from a pipeline script?
>>> Thanks,
>>> Mark Waite

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 
For more options, visit https://groups.google.com/d/optout.

Reply via email to