branch name in Jenkins regular pipeline job











up vote
1
down vote

favorite












For a Jenkins pipeline job having web-hook trigger in Git/Bitbucket, each repo push triggers pipeline job.



How we can know branch name in pipeline job on which push/change is committed.



I need this branch name to execute pipeline job whenever push to specific branch happened (devel/master).



Note: Jenkins pipeline job is not s multibranch pipeline job.










share|improve this question
























  • This question may be better suited for the DevOps SE, since it's not really a unix-specific question.
    – jayhendren
    Jan 10 at 17:31















up vote
1
down vote

favorite












For a Jenkins pipeline job having web-hook trigger in Git/Bitbucket, each repo push triggers pipeline job.



How we can know branch name in pipeline job on which push/change is committed.



I need this branch name to execute pipeline job whenever push to specific branch happened (devel/master).



Note: Jenkins pipeline job is not s multibranch pipeline job.










share|improve this question
























  • This question may be better suited for the DevOps SE, since it's not really a unix-specific question.
    – jayhendren
    Jan 10 at 17:31













up vote
1
down vote

favorite









up vote
1
down vote

favorite











For a Jenkins pipeline job having web-hook trigger in Git/Bitbucket, each repo push triggers pipeline job.



How we can know branch name in pipeline job on which push/change is committed.



I need this branch name to execute pipeline job whenever push to specific branch happened (devel/master).



Note: Jenkins pipeline job is not s multibranch pipeline job.










share|improve this question















For a Jenkins pipeline job having web-hook trigger in Git/Bitbucket, each repo push triggers pipeline job.



How we can know branch name in pipeline job on which push/change is committed.



I need this branch name to execute pipeline job whenever push to specific branch happened (devel/master).



Note: Jenkins pipeline job is not s multibranch pipeline job.







git jenkins






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 at 14:13









Rui F Ribeiro

38.3k1475126




38.3k1475126










asked Jan 9 at 8:43









AVJ

182116




182116












  • This question may be better suited for the DevOps SE, since it's not really a unix-specific question.
    – jayhendren
    Jan 10 at 17:31


















  • This question may be better suited for the DevOps SE, since it's not really a unix-specific question.
    – jayhendren
    Jan 10 at 17:31
















This question may be better suited for the DevOps SE, since it's not really a unix-specific question.
– jayhendren
Jan 10 at 17:31




This question may be better suited for the DevOps SE, since it's not really a unix-specific question.
– jayhendren
Jan 10 at 17:31










1 Answer
1






active

oldest

votes

















up vote
0
down vote













This depends entirely on how you're triggering the jobs from Bitbucket. For instance, I am using the pull-request-notifier plugin for Bitbucket to trigger my jobs, and one of the parameters it offers is the branch that the pull request was created from. You can then feed this information into Jenkins however you want; one example would be to pass it as a parameter to a parameterized job. Different hooks or triggers will have different options available; some might not even offer the ability to pass the branch name.



However, I would highly recommend using the Bitbucket Branch Source plugin for Jenkins instead. It automatically creates Jenkins jobs for every branch and pull request of every project in a Bitbucket project. This makes it much, much easier to work in Jenkins with repositories that have multiple branches.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    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',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2funix.stackexchange.com%2fquestions%2f415759%2fbranch-name-in-jenkins-regular-pipeline-job%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








    up vote
    0
    down vote













    This depends entirely on how you're triggering the jobs from Bitbucket. For instance, I am using the pull-request-notifier plugin for Bitbucket to trigger my jobs, and one of the parameters it offers is the branch that the pull request was created from. You can then feed this information into Jenkins however you want; one example would be to pass it as a parameter to a parameterized job. Different hooks or triggers will have different options available; some might not even offer the ability to pass the branch name.



    However, I would highly recommend using the Bitbucket Branch Source plugin for Jenkins instead. It automatically creates Jenkins jobs for every branch and pull request of every project in a Bitbucket project. This makes it much, much easier to work in Jenkins with repositories that have multiple branches.






    share|improve this answer

























      up vote
      0
      down vote













      This depends entirely on how you're triggering the jobs from Bitbucket. For instance, I am using the pull-request-notifier plugin for Bitbucket to trigger my jobs, and one of the parameters it offers is the branch that the pull request was created from. You can then feed this information into Jenkins however you want; one example would be to pass it as a parameter to a parameterized job. Different hooks or triggers will have different options available; some might not even offer the ability to pass the branch name.



      However, I would highly recommend using the Bitbucket Branch Source plugin for Jenkins instead. It automatically creates Jenkins jobs for every branch and pull request of every project in a Bitbucket project. This makes it much, much easier to work in Jenkins with repositories that have multiple branches.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        This depends entirely on how you're triggering the jobs from Bitbucket. For instance, I am using the pull-request-notifier plugin for Bitbucket to trigger my jobs, and one of the parameters it offers is the branch that the pull request was created from. You can then feed this information into Jenkins however you want; one example would be to pass it as a parameter to a parameterized job. Different hooks or triggers will have different options available; some might not even offer the ability to pass the branch name.



        However, I would highly recommend using the Bitbucket Branch Source plugin for Jenkins instead. It automatically creates Jenkins jobs for every branch and pull request of every project in a Bitbucket project. This makes it much, much easier to work in Jenkins with repositories that have multiple branches.






        share|improve this answer












        This depends entirely on how you're triggering the jobs from Bitbucket. For instance, I am using the pull-request-notifier plugin for Bitbucket to trigger my jobs, and one of the parameters it offers is the branch that the pull request was created from. You can then feed this information into Jenkins however you want; one example would be to pass it as a parameter to a parameterized job. Different hooks or triggers will have different options available; some might not even offer the ability to pass the branch name.



        However, I would highly recommend using the Bitbucket Branch Source plugin for Jenkins instead. It automatically creates Jenkins jobs for every branch and pull request of every project in a Bitbucket project. This makes it much, much easier to work in Jenkins with repositories that have multiple branches.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 10 at 17:30









        jayhendren

        5,29221444




        5,29221444






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f415759%2fbranch-name-in-jenkins-regular-pipeline-job%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

            Entries order in /etc/network/interfaces

            新発田市

            Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)