Hi Rob,
AFAIK, git command of workflow plugin does not support that.
Use GeneralSCM for that, like described
at
https://github.com/jenkinsci/workflow-plugin/blob/master/scm-step/README.md#generic-scm-step.
I've defined for that a special function at the start of my workflow script:
def gitCheckout(url, branch, credentials) {
checkout changelog: true, poll: true, scm: [$class: 'GitSCM', branches:
[[name: branch]], userRemoteConfigs: [[credentialsId: credentials, url:
url]]]
}
and later in code just use
gitCheckout('https://github.com/XXXXX/XXXXXX.git', "remotes/origin/master",
"XXXX-XXX-XXXX-XXXXX")
Regards,
Timur
вторник, 27 января 2015 г., 19:15:48 UTC+3 пользователь Rob Mandeville
написал:
>
> I am using:
>
> · Jenkins 1.580.2
>
> · GIT client plugin 1.15.0
>
> · GIT plugin 2.3.4
>
> · Workflow plugins 1.1
>
> · Credentials plugin 1.22
>
>
>
> We use GitLab for source control and do not allow anonymous access of any
> kind. We use the Credentials plugin, have put in credentials allowing us
> access to Git, and on our normal projects, we simply give Git these
> pre-loaded credentials. Now, I’m trying to create a Workflow job.
>
>
>
> I can’t find any doc which says how to feed credentials to Git, so I went
> to the credentials plugin and pulled the plugin ID from the URL. I then
> wrote the following Groovy CPS DSL script (without the redactions,
> obviously):
>
>
>
>
>
> steps.stage('Setup')
>
> node('mock_builder') {
>
> String templateUrl = 'git@URL_REDACTED'
>
> steps.git(url: templateUrl, credentialsId: 'ID_REDACTED')
>
> sh 'echo hello world'
>
> }
>
>
>
> The job gets stuck in the SCM step and exits with the following output:
>
>
>
> Running: Setup
>
> Entering stage Setup
>
> Proceeding
>
> Running: Allocate node : Start
>
> Running on mock_builder in
> C:\Windows\TEMP\hudson1572436821107746068tmp\workspace\Try a Workflow
>
> Running: Allocate node : Body : Start
>
> Running: Git
>
> > git.exe rev-parse --is-inside-work-tree # timeout=10
>
> Fetching changes from the remote Git repository
>
> > git.exe config remote.origin.url git@URL_REDACTED # timeout=10
>
> Fetching upstream changes from git@URL_REDACTED
>
> > git.exe --version # timeout=10
>
> > git.exe -c core.askpass=true fetch --tags --progress git@URL_REDACTED
> +refs/heads/*:refs/remotes/origin/*
>
> ERROR: Timeout after 10 minutes
>
> ERROR <http://stacktrace.jenkins-ci.org/search?query=ERROR>: Error fetching
> remote repo 'origin'
>
> Running <http://stacktrace.jenkins-ci.org/search?query=Running>: Allocate
> node : Body : End
>
> Running: Allocate node : End
>
> Running: End of Workflow
>
> ERROR: Error fetching remote repo 'origin'
>
> Finished <http://stacktrace.jenkins-ci.org/search?query=Finished>: FAILURE
>
>
>
> I’m wondering where the “-c core.askpass=true” came from, and figuring
> that it was waiting to receive a password via standard input.
>
> Is there any way, with or without the credentials plugin, to feed Git
> credentials to this project?
>
>
>
> Thanks in advance,
>
>
>
> --Rob
>
> ------------------------------
> This e-mail and the information, including any attachments it contains,
> are intended to be a confidential communication only to the person or
> entity to whom it is addressed and may contain information that is
> privileged. If the reader of this message is not the intended recipient,
> you are hereby notified that any dissemination, distribution or copying of
> this communication is strictly prohibited. If you have received this
> communication in error, please immediately notify the sender and destroy
> the original message.
>
> Thank you.
>
> Please consider the environment before printing this email.
>
--
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/c2500d38-3814-42b9-9e49-446974054cd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.