branch name in Jenkins regular pipeline job












1















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
















bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • This question may be better suited for the DevOps SE, since it's not really a unix-specific question.

    – jayhendren
    Jan 10 '18 at 17:31
















1















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
















bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • This question may be better suited for the DevOps SE, since it's not really a unix-specific question.

    – jayhendren
    Jan 10 '18 at 17:31














1












1








1








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 '18 at 14:13









Rui F Ribeiro

39.7k1479132




39.7k1479132










asked Jan 9 '18 at 8:43









AVJAVJ

182216




182216





bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • This question may be better suited for the DevOps SE, since it's not really a unix-specific question.

    – jayhendren
    Jan 10 '18 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 '18 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 '18 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 '18 at 17:31










1 Answer
1






active

oldest

votes


















0














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',
    autoActivateHeartbeat: false,
    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









    0














    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




























      0














      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


























        0












        0








        0







        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 '18 at 17:30









        jayhendrenjayhendren

        5,40721444




        5,40721444






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%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

            CARDNET

            Boot-repair Failure: Unable to locate package grub-common:i386

            濃尾地震