I have installed and configured git parameter plug in so I can deploy a job and select the branch with the code I wrote instead of code of master. Thing is that eventhough I select the branch I created, the job starts running on master. Here are some screenshots of what I have configured and when job is run.

       

        1. br.JPG
          br.JPG
          39 kB
        2. Capture.JPG
          Capture.JPG
          79 kB
        3. Capture.JPG
          Capture.JPG
          59 kB
        4. Capture.JPG
          Capture.JPG
          50 kB
        5. Capture.JPG
          Capture.JPG
          35 kB
        6. Capture1.JPG
          Capture1.JPG
          86 kB
        7. Capture2.JPG
          Capture2.JPG
          34 kB
        8. Capture3.JPG
          Capture3.JPG
          53 kB
        9. Capture4.JPG
          Capture4.JPG
          57 kB
        10. chose_branch.png
          chose_branch.png
          34 kB
        11. logs.png
          logs.png
          184 kB
        12. pip2.JPG
          pip2.JPG
          119 kB
        13. pip2.JPG
          pip2.JPG
          119 kB
        14. pip2.JPG
          pip2.JPG
          119 kB
        15. pipe1.JPG
          pipe1.JPG
          48 kB
        16. pipe1.JPG
          pipe1.JPG
          48 kB
        17. pipe1.JPG
          pipe1.JPG
          48 kB
        18. pipe3.JPG
          pipe3.JPG
          38 kB
        19. pipe4.JPG
          pipe4.JPG
          50 kB
        20. simple_use_plugin.png
          simple_use_plugin.png
          159 kB

          [JENKINS-50131] git parameter

          Mark Waite added a comment -

          klimas7 as far as I can tell, it is not fixed. That path through the git plugin code (from the SCM API, I believe) uses a refspec which intentionally selects only the specific branch. JENKINS-49758 is the bug that reports variables in the refspec are not expanded. Until JENKINS-49758 is fixed, this bug won't be fixed.

          Mark Waite added a comment - klimas7 as far as I can tell, it is not fixed. That path through the git plugin code (from the SCM API, I believe) uses a refspec which intentionally selects only the specific branch. JENKINS-49758 is the bug that reports variables in the refspec are not expanded. Until JENKINS-49758 is fixed, this bug won't be fixed.

           Ok, so if this can´t be done with the plug in, how can I achieve running a JOB but instead of running master branch from repo, to be run from a different branch.

          I don´t want to modify master because is being used for the today´s deploys. I created a different branch, Now How can I do a checkout to that branch and using it when running the job in jenkins? Has to be a way or not? markewaite, klimas7 ?

          I don´t know how to do this, please help!

           

          Thank you

          guillermo casco added a comment -  Ok, so if this can´t be done with the plug in, how can I achieve running a JOB but instead of running master branch from repo, to be run from a different branch. I don´t want to modify master because is being used for the today´s deploys. I created a different branch, Now How can I do a checkout to that branch and using it when running the job in jenkins? Has to be a way or not? markewaite , klimas7 ? I don´t know how to do this, please help!   Thank you

          Mark Waite added a comment - - edited

          yiyito until that bug is fixed, I think your choices are:

          • Use a multi-branch Pipeline instead of a single Pipeline job and allow it to manage the branch checkout. Multi-branch Pipeline will create a job for each branch that contains a Jenkinsfile and will remove those jobs when the branch is deleted. Then there is no need to select from pick lists to choose branches since all the branches that contain a Jenkinsfile are always built
          • Use a Freestyle job instead of a single Pipeline job and allow it to manage the branch checkout. Then the user can select from a pick list to choose the branch they want to build

          Mark Waite added a comment - - edited yiyito until that bug is fixed, I think your choices are: Use a multi-branch Pipeline instead of a single Pipeline job and allow it to manage the branch checkout. Multi-branch Pipeline will create a job for each branch that contains a Jenkinsfile and will remove those jobs when the branch is deleted. Then there is no need to select from pick lists to choose branches since all the branches that contain a Jenkinsfile are always built Use a Freestyle job instead of a single Pipeline job and allow it to manage the branch checkout. Then the user can select from a pick list to choose the branch they want to build

          what do you mean multibranch? Is already a multibranch pipeline. Master branch has a  groovy file which perform some steps inside the job (compile, build, etc), and the branch I created has another groovy which implement those same steps as master and also others I´m adding (compile, build, run tests, etc).

          Maybe yo refer to this option? adding more branches in there? check image.

          guillermo casco added a comment - what do you mean multibranch? Is already a multibranch pipeline. Master branch has a  groovy file which perform some steps inside the job (compile, build, etc), and the branch I created has another groovy which implement those same steps as master and also others I´m adding (compile, build, run tests, etc). Maybe yo refer to this option? adding more branches in there? check image.

          Mark Waite added a comment -

          Refer to the "Build a multibranch project" tutorial to see the difference between the job you have defined which uses a single job and switches between branches with that single job, and a multi-branch Pipeline which automatically creates a job per branch.

          Mark Waite added a comment - Refer to the " Build a multibranch project " tutorial to see the difference between the job you have defined which uses a single job and switches between branches with that single job, and a multi-branch Pipeline which automatically creates a job per branch.

          ok and the last one: 

          • Use a Freestyle job instead of a single Pipeline job and allow it to manage the branch checkout. Then the user can select from a pick list to choose the branch they want to build

          Is this better? is the branch checkout management UI configured through jenkins console? 

          first option you said involves docker and other stuff to configure and looks a little bit messy. Doable, but messy

          thanks budy

          guillermo casco added a comment - ok and the last one:  Use a Freestyle job instead of a single Pipeline job and allow it to manage the branch checkout. Then the user can select from a pick list to choose the branch they want to build Is this better? is the branch checkout management UI configured through jenkins console?  first option you said involves docker and other stuff to configure and looks a little bit messy. Doable, but messy thanks budy

          Mark Waite added a comment - - edited

          yiyito multi-branch Pipelines do not require docker and are much less messy than a single job which switches between different branches. Refer to the simpler multi-branch Pipeline tutorial for an example of how easy it is.

          Mark Waite added a comment - - edited yiyito multi-branch Pipelines do not require docker and are much less messy than a single job which switches between different branches. Refer to the simpler multi-branch Pipeline tutorial for an example of how easy it is.

          ok will try that, thank you for for your help!

          Regards.-

          guillermo casco added a comment - ok will try that, thank you for for your help! Regards.-

          Is this some kind of another bug or something? I implemented multibranch pipeline as you suggsted markewaite and is still running master  . check images. Is there some kind of configuration I´m missing? 

           

          guillermo casco added a comment - Is this some kind of another bug or something? I implemented multibranch pipeline as you suggsted markewaite and is still running master  . check images. Is there some kind of configuration I´m missing?   

          Mark Waite added a comment -

          yiyito be sure that your Jenkinsfile on the branch is not inadvertently specifying that it should checkout the master branch.

          Mark Waite added a comment - yiyito be sure that your Jenkinsfile on the branch is not inadvertently specifying that it should checkout the master branch.

            klimas7 Boguslaw Klimas
            yiyito guillermo casco
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: