Configure block in Jenkins pipelinejob using DSL?










0














Trying to write a DSL Jenkins pipeline job using jobs-dsl and not sure if I'm hitting a couple of pipeline job limitations or am missing something more fundamental.



1 - Configuring "Polling ignores commits in certain paths" under "Additional Behaviours" using the configure block does not seem to be working as expected in the pipeline job; I have tested and this configure block works as expected in a freestyle job dsl. Searched and couldn't find anything relevant - can someone confirm if the below is supported/not supported within the below pipeline job?



 pipelineJob("ProjA/pipeline") 

logRotator

daysToKeep 10
numToKeep 30

definition

cpsScm

scm

git('git@github.com:sample-org/pipeline.git', '*/develop')

configure gitScm ->
gitScm / 'extensions' << 'hudson.plugins.git.extensions.impl.PathRestriction'
excludedRegions('sample/dirs')







2 - How do we pass credentials to the git under scm block under pipeline? Works for freestyle jobs but having trouble getting it to work here



Thanks in advance.










share|improve this question


























    0














    Trying to write a DSL Jenkins pipeline job using jobs-dsl and not sure if I'm hitting a couple of pipeline job limitations or am missing something more fundamental.



    1 - Configuring "Polling ignores commits in certain paths" under "Additional Behaviours" using the configure block does not seem to be working as expected in the pipeline job; I have tested and this configure block works as expected in a freestyle job dsl. Searched and couldn't find anything relevant - can someone confirm if the below is supported/not supported within the below pipeline job?



     pipelineJob("ProjA/pipeline") 

    logRotator

    daysToKeep 10
    numToKeep 30

    definition

    cpsScm

    scm

    git('git@github.com:sample-org/pipeline.git', '*/develop')

    configure gitScm ->
    gitScm / 'extensions' << 'hudson.plugins.git.extensions.impl.PathRestriction'
    excludedRegions('sample/dirs')







    2 - How do we pass credentials to the git under scm block under pipeline? Works for freestyle jobs but having trouble getting it to work here



    Thanks in advance.










    share|improve this question
























      0












      0








      0







      Trying to write a DSL Jenkins pipeline job using jobs-dsl and not sure if I'm hitting a couple of pipeline job limitations or am missing something more fundamental.



      1 - Configuring "Polling ignores commits in certain paths" under "Additional Behaviours" using the configure block does not seem to be working as expected in the pipeline job; I have tested and this configure block works as expected in a freestyle job dsl. Searched and couldn't find anything relevant - can someone confirm if the below is supported/not supported within the below pipeline job?



       pipelineJob("ProjA/pipeline") 

      logRotator

      daysToKeep 10
      numToKeep 30

      definition

      cpsScm

      scm

      git('git@github.com:sample-org/pipeline.git', '*/develop')

      configure gitScm ->
      gitScm / 'extensions' << 'hudson.plugins.git.extensions.impl.PathRestriction'
      excludedRegions('sample/dirs')







      2 - How do we pass credentials to the git under scm block under pipeline? Works for freestyle jobs but having trouble getting it to work here



      Thanks in advance.










      share|improve this question













      Trying to write a DSL Jenkins pipeline job using jobs-dsl and not sure if I'm hitting a couple of pipeline job limitations or am missing something more fundamental.



      1 - Configuring "Polling ignores commits in certain paths" under "Additional Behaviours" using the configure block does not seem to be working as expected in the pipeline job; I have tested and this configure block works as expected in a freestyle job dsl. Searched and couldn't find anything relevant - can someone confirm if the below is supported/not supported within the below pipeline job?



       pipelineJob("ProjA/pipeline") 

      logRotator

      daysToKeep 10
      numToKeep 30

      definition

      cpsScm

      scm

      git('git@github.com:sample-org/pipeline.git', '*/develop')

      configure gitScm ->
      gitScm / 'extensions' << 'hudson.plugins.git.extensions.impl.PathRestriction'
      excludedRegions('sample/dirs')







      2 - How do we pass credentials to the git under scm block under pipeline? Works for freestyle jobs but having trouble getting it to work here



      Thanks in advance.







      jenkins jenkins-pipeline jenkins-job-dsl






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 at 14:41









      Innocentspirit

      15




      15






















          1 Answer
          1






          active

          oldest

          votes


















          1














          FYI for normal pipeline



          Git checkout using credentials referring to the git plugin step :



           stage('checkout') 
          git credentialsId: '<credentialsID from credentials plugin>',
          url: 'git@repository.foo/repoName.git',
          branch: 'master'



          Reg. scm plugin step



           stage('checkout') 
          checkout scm: [$class: 'GitSCM',
          userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
          credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
          branches: [[name:'refs/tags/TAGNAME']]],
          poll:false


          stage('checkout')
          checkout scm: [$class: 'GitSCM',
          userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
          credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
          branches: [[name:'BRANCHNAME']]],
          poll:false



          And I was never looking for poll if it works or not






          share|improve this answer






















          • But this is for usage in a Jenkinsfile within jenkins-pipeline, not for jenkins-job-dsl.
            – StephenKing
            Nov 12 at 18:07






          • 1




            Which is not necessarily wrong.. just it could be clarified that this can not just be inserted into the snipped posted by the author.
            – StephenKing
            Nov 12 at 18:08










          • Ah, he is looking for the code to shared libraries, etc..
            – xxxvodnikxxx
            Nov 13 at 6:37










          • Nope, Job DSL, a separate plugin (see plugin site)
            – StephenKing
            Nov 13 at 6:40






          • 1




            Thanks @xxxvodnikxxx - but as StephenKing mentions looking for a jobs-dsl equivalent to use within the pipelinejob
            – Innocentspirit
            Nov 13 at 11:14











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264493%2fconfigure-block-in-jenkins-pipelinejob-using-dsl%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          FYI for normal pipeline



          Git checkout using credentials referring to the git plugin step :



           stage('checkout') 
          git credentialsId: '<credentialsID from credentials plugin>',
          url: 'git@repository.foo/repoName.git',
          branch: 'master'



          Reg. scm plugin step



           stage('checkout') 
          checkout scm: [$class: 'GitSCM',
          userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
          credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
          branches: [[name:'refs/tags/TAGNAME']]],
          poll:false


          stage('checkout')
          checkout scm: [$class: 'GitSCM',
          userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
          credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
          branches: [[name:'BRANCHNAME']]],
          poll:false



          And I was never looking for poll if it works or not






          share|improve this answer






















          • But this is for usage in a Jenkinsfile within jenkins-pipeline, not for jenkins-job-dsl.
            – StephenKing
            Nov 12 at 18:07






          • 1




            Which is not necessarily wrong.. just it could be clarified that this can not just be inserted into the snipped posted by the author.
            – StephenKing
            Nov 12 at 18:08










          • Ah, he is looking for the code to shared libraries, etc..
            – xxxvodnikxxx
            Nov 13 at 6:37










          • Nope, Job DSL, a separate plugin (see plugin site)
            – StephenKing
            Nov 13 at 6:40






          • 1




            Thanks @xxxvodnikxxx - but as StephenKing mentions looking for a jobs-dsl equivalent to use within the pipelinejob
            – Innocentspirit
            Nov 13 at 11:14
















          1














          FYI for normal pipeline



          Git checkout using credentials referring to the git plugin step :



           stage('checkout') 
          git credentialsId: '<credentialsID from credentials plugin>',
          url: 'git@repository.foo/repoName.git',
          branch: 'master'



          Reg. scm plugin step



           stage('checkout') 
          checkout scm: [$class: 'GitSCM',
          userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
          credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
          branches: [[name:'refs/tags/TAGNAME']]],
          poll:false


          stage('checkout')
          checkout scm: [$class: 'GitSCM',
          userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
          credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
          branches: [[name:'BRANCHNAME']]],
          poll:false



          And I was never looking for poll if it works or not






          share|improve this answer






















          • But this is for usage in a Jenkinsfile within jenkins-pipeline, not for jenkins-job-dsl.
            – StephenKing
            Nov 12 at 18:07






          • 1




            Which is not necessarily wrong.. just it could be clarified that this can not just be inserted into the snipped posted by the author.
            – StephenKing
            Nov 12 at 18:08










          • Ah, he is looking for the code to shared libraries, etc..
            – xxxvodnikxxx
            Nov 13 at 6:37










          • Nope, Job DSL, a separate plugin (see plugin site)
            – StephenKing
            Nov 13 at 6:40






          • 1




            Thanks @xxxvodnikxxx - but as StephenKing mentions looking for a jobs-dsl equivalent to use within the pipelinejob
            – Innocentspirit
            Nov 13 at 11:14














          1












          1








          1






          FYI for normal pipeline



          Git checkout using credentials referring to the git plugin step :



           stage('checkout') 
          git credentialsId: '<credentialsID from credentials plugin>',
          url: 'git@repository.foo/repoName.git',
          branch: 'master'



          Reg. scm plugin step



           stage('checkout') 
          checkout scm: [$class: 'GitSCM',
          userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
          credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
          branches: [[name:'refs/tags/TAGNAME']]],
          poll:false


          stage('checkout')
          checkout scm: [$class: 'GitSCM',
          userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
          credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
          branches: [[name:'BRANCHNAME']]],
          poll:false



          And I was never looking for poll if it works or not






          share|improve this answer














          FYI for normal pipeline



          Git checkout using credentials referring to the git plugin step :



           stage('checkout') 
          git credentialsId: '<credentialsID from credentials plugin>',
          url: 'git@repository.foo/repoName.git',
          branch: 'master'



          Reg. scm plugin step



           stage('checkout') 
          checkout scm: [$class: 'GitSCM',
          userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
          credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
          branches: [[name:'refs/tags/TAGNAME']]],
          poll:false


          stage('checkout')
          checkout scm: [$class: 'GitSCM',
          userRemoteConfigs: [[url: 'https://repository.foo/git/fooRepoName.git' ,
          credentialsId: 'credentialsIDToUseFromCredentialsPlugin']],
          branches: [[name:'BRANCHNAME']]],
          poll:false



          And I was never looking for poll if it works or not







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 at 6:37

























          answered Nov 12 at 15:58









          xxxvodnikxxx

          70311026




          70311026











          • But this is for usage in a Jenkinsfile within jenkins-pipeline, not for jenkins-job-dsl.
            – StephenKing
            Nov 12 at 18:07






          • 1




            Which is not necessarily wrong.. just it could be clarified that this can not just be inserted into the snipped posted by the author.
            – StephenKing
            Nov 12 at 18:08










          • Ah, he is looking for the code to shared libraries, etc..
            – xxxvodnikxxx
            Nov 13 at 6:37










          • Nope, Job DSL, a separate plugin (see plugin site)
            – StephenKing
            Nov 13 at 6:40






          • 1




            Thanks @xxxvodnikxxx - but as StephenKing mentions looking for a jobs-dsl equivalent to use within the pipelinejob
            – Innocentspirit
            Nov 13 at 11:14

















          • But this is for usage in a Jenkinsfile within jenkins-pipeline, not for jenkins-job-dsl.
            – StephenKing
            Nov 12 at 18:07






          • 1




            Which is not necessarily wrong.. just it could be clarified that this can not just be inserted into the snipped posted by the author.
            – StephenKing
            Nov 12 at 18:08










          • Ah, he is looking for the code to shared libraries, etc..
            – xxxvodnikxxx
            Nov 13 at 6:37










          • Nope, Job DSL, a separate plugin (see plugin site)
            – StephenKing
            Nov 13 at 6:40






          • 1




            Thanks @xxxvodnikxxx - but as StephenKing mentions looking for a jobs-dsl equivalent to use within the pipelinejob
            – Innocentspirit
            Nov 13 at 11:14
















          But this is for usage in a Jenkinsfile within jenkins-pipeline, not for jenkins-job-dsl.
          – StephenKing
          Nov 12 at 18:07




          But this is for usage in a Jenkinsfile within jenkins-pipeline, not for jenkins-job-dsl.
          – StephenKing
          Nov 12 at 18:07




          1




          1




          Which is not necessarily wrong.. just it could be clarified that this can not just be inserted into the snipped posted by the author.
          – StephenKing
          Nov 12 at 18:08




          Which is not necessarily wrong.. just it could be clarified that this can not just be inserted into the snipped posted by the author.
          – StephenKing
          Nov 12 at 18:08












          Ah, he is looking for the code to shared libraries, etc..
          – xxxvodnikxxx
          Nov 13 at 6:37




          Ah, he is looking for the code to shared libraries, etc..
          – xxxvodnikxxx
          Nov 13 at 6:37












          Nope, Job DSL, a separate plugin (see plugin site)
          – StephenKing
          Nov 13 at 6:40




          Nope, Job DSL, a separate plugin (see plugin site)
          – StephenKing
          Nov 13 at 6:40




          1




          1




          Thanks @xxxvodnikxxx - but as StephenKing mentions looking for a jobs-dsl equivalent to use within the pipelinejob
          – Innocentspirit
          Nov 13 at 11:14





          Thanks @xxxvodnikxxx - but as StephenKing mentions looking for a jobs-dsl equivalent to use within the pipelinejob
          – Innocentspirit
          Nov 13 at 11:14


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264493%2fconfigure-block-in-jenkins-pipelinejob-using-dsl%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党