Poll SCM for a specific branch Jenkins












0















I have a Github project with many branches.



Example

master
staging
feature-1
feature-2


I have a Jenkins job that has the "Poll SCM" option enabled with the following cronjob (10 7,9,11,13,15,17,19 * * 1-5)



However, this job will kick off when a change is made to master also.



I want a Jenkins job to only kick off if a commit to the staging branch.



Here is an output of the polling logs



Started on Nov 20, 2018 1:10:00 PM
no polling baseline in /var/jenkins_workspace/workspace/Staging-ALL-Deploy@libs/jenkins-pipeline-global-lib on
Using strategy: Default
[poll] Last Built Revision: Revision efccc8e212470802d64537e0a5e710f9b5c063b6 (refs/remotes/origin/staging)
> git --version # timeout=10
> git ls-remote -h http://git.company.com/org/repo.git # timeout=10
Found 56 remote heads on http://git.company.com/org/repo.git
[poll] Latest remote head revision on refs/heads/staging is: efccc8e212470802d64537e0a5e710f9b5c063b6 - already built by 171
Using strategy: Default
[poll] Last Built Revision: Revision efccc8e212470802d64537e0a5e710f9b5c063b6 (refs/remotes/origin/staging)
> git --version # timeout=10
> git ls-remote -h http://git.company.com/org/repo.git # timeout=10
Found 56 remote heads on http://git.company.com/org/repo.git
[poll] Latest remote head revision on refs/heads/master is: 865459e59ef5f91fddbd7453d9f2205560327c44
Done. Took 0.46 sec
Changes found


Is this possible?



Thanks
John










share|improve this question



























    0















    I have a Github project with many branches.



    Example

    master
    staging
    feature-1
    feature-2


    I have a Jenkins job that has the "Poll SCM" option enabled with the following cronjob (10 7,9,11,13,15,17,19 * * 1-5)



    However, this job will kick off when a change is made to master also.



    I want a Jenkins job to only kick off if a commit to the staging branch.



    Here is an output of the polling logs



    Started on Nov 20, 2018 1:10:00 PM
    no polling baseline in /var/jenkins_workspace/workspace/Staging-ALL-Deploy@libs/jenkins-pipeline-global-lib on
    Using strategy: Default
    [poll] Last Built Revision: Revision efccc8e212470802d64537e0a5e710f9b5c063b6 (refs/remotes/origin/staging)
    > git --version # timeout=10
    > git ls-remote -h http://git.company.com/org/repo.git # timeout=10
    Found 56 remote heads on http://git.company.com/org/repo.git
    [poll] Latest remote head revision on refs/heads/staging is: efccc8e212470802d64537e0a5e710f9b5c063b6 - already built by 171
    Using strategy: Default
    [poll] Last Built Revision: Revision efccc8e212470802d64537e0a5e710f9b5c063b6 (refs/remotes/origin/staging)
    > git --version # timeout=10
    > git ls-remote -h http://git.company.com/org/repo.git # timeout=10
    Found 56 remote heads on http://git.company.com/org/repo.git
    [poll] Latest remote head revision on refs/heads/master is: 865459e59ef5f91fddbd7453d9f2205560327c44
    Done. Took 0.46 sec
    Changes found


    Is this possible?



    Thanks
    John










    share|improve this question

























      0












      0








      0








      I have a Github project with many branches.



      Example

      master
      staging
      feature-1
      feature-2


      I have a Jenkins job that has the "Poll SCM" option enabled with the following cronjob (10 7,9,11,13,15,17,19 * * 1-5)



      However, this job will kick off when a change is made to master also.



      I want a Jenkins job to only kick off if a commit to the staging branch.



      Here is an output of the polling logs



      Started on Nov 20, 2018 1:10:00 PM
      no polling baseline in /var/jenkins_workspace/workspace/Staging-ALL-Deploy@libs/jenkins-pipeline-global-lib on
      Using strategy: Default
      [poll] Last Built Revision: Revision efccc8e212470802d64537e0a5e710f9b5c063b6 (refs/remotes/origin/staging)
      > git --version # timeout=10
      > git ls-remote -h http://git.company.com/org/repo.git # timeout=10
      Found 56 remote heads on http://git.company.com/org/repo.git
      [poll] Latest remote head revision on refs/heads/staging is: efccc8e212470802d64537e0a5e710f9b5c063b6 - already built by 171
      Using strategy: Default
      [poll] Last Built Revision: Revision efccc8e212470802d64537e0a5e710f9b5c063b6 (refs/remotes/origin/staging)
      > git --version # timeout=10
      > git ls-remote -h http://git.company.com/org/repo.git # timeout=10
      Found 56 remote heads on http://git.company.com/org/repo.git
      [poll] Latest remote head revision on refs/heads/master is: 865459e59ef5f91fddbd7453d9f2205560327c44
      Done. Took 0.46 sec
      Changes found


      Is this possible?



      Thanks
      John










      share|improve this question














      I have a Github project with many branches.



      Example

      master
      staging
      feature-1
      feature-2


      I have a Jenkins job that has the "Poll SCM" option enabled with the following cronjob (10 7,9,11,13,15,17,19 * * 1-5)



      However, this job will kick off when a change is made to master also.



      I want a Jenkins job to only kick off if a commit to the staging branch.



      Here is an output of the polling logs



      Started on Nov 20, 2018 1:10:00 PM
      no polling baseline in /var/jenkins_workspace/workspace/Staging-ALL-Deploy@libs/jenkins-pipeline-global-lib on
      Using strategy: Default
      [poll] Last Built Revision: Revision efccc8e212470802d64537e0a5e710f9b5c063b6 (refs/remotes/origin/staging)
      > git --version # timeout=10
      > git ls-remote -h http://git.company.com/org/repo.git # timeout=10
      Found 56 remote heads on http://git.company.com/org/repo.git
      [poll] Latest remote head revision on refs/heads/staging is: efccc8e212470802d64537e0a5e710f9b5c063b6 - already built by 171
      Using strategy: Default
      [poll] Last Built Revision: Revision efccc8e212470802d64537e0a5e710f9b5c063b6 (refs/remotes/origin/staging)
      > git --version # timeout=10
      > git ls-remote -h http://git.company.com/org/repo.git # timeout=10
      Found 56 remote heads on http://git.company.com/org/repo.git
      [poll] Latest remote head revision on refs/heads/master is: 865459e59ef5f91fddbd7453d9f2205560327c44
      Done. Took 0.46 sec
      Changes found


      Is this possible?



      Thanks
      John







      git jenkins






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 '18 at 19:31









      JPHamlettJPHamlett

      896




      896
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You can set which branch you want to build with following way:



          Configure -> Source Code Management tab -> Branch to Build -> Branch specifier



          just write staging in this section. Then go to Build Triggers tab, select GitHub hook trigger for GITScm polling.



          Don't forget to add webhook <YOUR-JENKINS-URL>/github-webhook/ to your Github project and select sending push events as json.



          With this way, you can create a build whenever a push made to a specific branch. With pooling, it will pull the repository with given time intervals, which is way more costly.






          share|improve this answer























            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%2f53400257%2fpoll-scm-for-a-specific-branch-jenkins%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









            0














            You can set which branch you want to build with following way:



            Configure -> Source Code Management tab -> Branch to Build -> Branch specifier



            just write staging in this section. Then go to Build Triggers tab, select GitHub hook trigger for GITScm polling.



            Don't forget to add webhook <YOUR-JENKINS-URL>/github-webhook/ to your Github project and select sending push events as json.



            With this way, you can create a build whenever a push made to a specific branch. With pooling, it will pull the repository with given time intervals, which is way more costly.






            share|improve this answer




























              0














              You can set which branch you want to build with following way:



              Configure -> Source Code Management tab -> Branch to Build -> Branch specifier



              just write staging in this section. Then go to Build Triggers tab, select GitHub hook trigger for GITScm polling.



              Don't forget to add webhook <YOUR-JENKINS-URL>/github-webhook/ to your Github project and select sending push events as json.



              With this way, you can create a build whenever a push made to a specific branch. With pooling, it will pull the repository with given time intervals, which is way more costly.






              share|improve this answer


























                0












                0








                0







                You can set which branch you want to build with following way:



                Configure -> Source Code Management tab -> Branch to Build -> Branch specifier



                just write staging in this section. Then go to Build Triggers tab, select GitHub hook trigger for GITScm polling.



                Don't forget to add webhook <YOUR-JENKINS-URL>/github-webhook/ to your Github project and select sending push events as json.



                With this way, you can create a build whenever a push made to a specific branch. With pooling, it will pull the repository with given time intervals, which is way more costly.






                share|improve this answer













                You can set which branch you want to build with following way:



                Configure -> Source Code Management tab -> Branch to Build -> Branch specifier



                just write staging in this section. Then go to Build Triggers tab, select GitHub hook trigger for GITScm polling.



                Don't forget to add webhook <YOUR-JENKINS-URL>/github-webhook/ to your Github project and select sending push events as json.



                With this way, you can create a build whenever a push made to a specific branch. With pooling, it will pull the repository with given time intervals, which is way more costly.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 20 '18 at 22:49









                SeçilSeçil

                214




                214






























                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400257%2fpoll-scm-for-a-specific-branch-jenkins%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

                    MongoDB - Not Authorized To Execute Command

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

                    Npm cannot find a required file even through it is in the searched directory