The git plugin has no facility to support creating a branch or pushing a
branch from a Pipeline step.

However, Pipeline can do it with an "sh" or "bat" step (depending on your
platform).

If your repository URL is an ssh URL ( g...@example.com:dir/repo.git or ssh:
//g...@example.com/dir/repo.git ) then you would use place the sh or bat
step inside an ssh-agent block.  The ssh-agent block starts ssh-agent and
then command line git will use ssh-agent to authenticate.

If your repository is an http or https URL (
https://example.com/dir/repo.git ) then you would use place the sh or bat
step inside a withCredentials block.  The withCredentials block extracts
username and password from the Jenkins credentials and makes them available
as a variable.  Place that variable inside the git URL in the sh or bat
step as in "git push https://${USERNAME}:${PASSWORD}@example.com/dir/repo";.
There are examples of withCredentials on the jenkins.io site to give good
techniques.

Mark Waite

On Tue, Aug 7, 2018 at 6:24 PM <jbro...@snapapp.com> wrote:

> Hi folks,
>
> I've googled extensively, but I haven't seen any documentation or answers
> on how to create a new git branch in Pipeline. I must be missing something
> obvious, but the Git plugin page doesn't indicate anything other than
> checking out code with credentials. Has anyone here used Jenkins to create
> a branch and then push it to remote?
>
> Thanks!
> Jack
>
> --
> 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/22a42e16-f0df-4dad-9e1f-3996cae8d40a%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/22a42e16-f0df-4dad-9e1f-3996cae8d40a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAO49JtFn_4Zte%3DmQ_QLDB4JvGiVbt8GY3WbxaqB9hMTxqjM61g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to