You can get the values from the global SCM variable i.e.:

checkout([
        $class                           : 'GitSCM',
        branches                         : [[$class: 'BranchSpec', name: 
git_reference]],
        doGenerateSubmoduleConfigurations: 
scm.doGenerateSubmoduleConfigurations,
        extensions                       : scm.extensions + [[$class: 
'CloneOption', noTags: false, reference: '', shallow: true]],
        submoduleCfg                     : [],
        userRemoteConfigs                : scm.userRemoteConfigs
])




On Friday, 1 July 2016 17:08:11 UTC+2, KP wrote:
>
> I am also interested in this, but for a slightly different reason. I want 
> to checkout into a sub-directory using git. I know that I can do that by 
> using syntax like: 
>
> checkout([$class: 'GitSCM', branches: [[name: '**']], 
> doGenerateSubmoduleConfigurations: false, extensions: [[$class: 
> 'RelativeTargetDirectory', relativeTargetDir: 'SUBDIR']], submoduleCfg: 
> [], userRemoteConfigs: [[credentialsId: 'XXXX', url: 'MYURL']]])
>
> but I need to supply the credentials and url (which I don't want to do in 
> a committed Jenkinsfile). Can I use the same credentials/url as would be 
> used in "checkout scm" somehow? Or extend "checkout scm" so that I can use 
> a subdirectory? Or do I need to set the parameters in the job and use those 
> instead?
>
> Thanks.
>
> On Tuesday, May 31, 2016 at 11:54:25 AM UTC-4, Antonio Muñiz wrote:
>>
>> You can use `checkout scm` which will clone the repository at the same 
>> revision than the previously fetched Jenkinsfile.
>>
>> On Tue, May 31, 2016 at 5:00 PM, Greg Smith <[email protected]> wrote:
>>
>>>
>>> Hello,
>>>
>>> I have a question that is probably obvious, but I couldn't seem to find 
>>> it anywhere.  Apologies for my newbie question:
>>>
>>> If I have a multibranch Pipeline job, does my Jenkinsfile need to do the 
>>> git extract?  Or should that be assumed as part of the retrieval of the 
>>> Jenkinsfile?
>>>
>>> For example, lets say I have project "MyProject", with branch "master", 
>>> with a Jenkins file like this:
>>>
>>> node() {
>>>    stage 'Checkout'
>>>    // git -- Do I need to do the git checkout here??
>>>    git credentialsId: '1ab8712b-28f4-498e-af0f-433b409675ea', url: 
>>> '[email protected]:smithgcovert/MyProject.git'
>>>
>>>   // build stuff
>>> }
>>>
>>> Now I branch master to "newtestbranch" -- it has the same Jenkinsfile at 
>>> the top.
>>>
>>> 1)  Do I even need the git extract step?  It would seem to be implied by 
>>> the fact that the Jenkins file was found in that branch... but it seems i 
>>> do from the testing I've done
>>> 2)  How can I pass the url and branch into the git step, so that I do 
>>> not put a path to the repo in the file that is checked in?  
>>>
>>> IE, I want the repo URL, and the branch being built, and the credentials 
>>> used to do the extract to all be defined by the same url, branch, creds 
>>> that were used to retrieve the Jenkinsfile.  It seems wrong to have any 
>>> url, branch or credential information in the Jenkinsfile -- is there a way 
>>> to say "extract the same as used to retrieve the Jenkinsfile"?
>>>
>>> Thanks,
>>> Greg
>>>
>>> -- 
>>> 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/549e1e95-d6f2-4c40-83b4-b731fdbf2ba6%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/jenkinsci-users/549e1e95-d6f2-4c40-83b4-b731fdbf2ba6%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Antonio Muñiz
>> Software Engineer
>> CloudBees, Inc.
>>
>

-- 
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/56357161-48f6-403a-8e96-ec417ecfc570%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to