Discussion:
Making the jenkins scm checkout smart
touseef
2018-10-30 06:43:14 UTC
Permalink
Hi ,

I have a source code repository having multiple branches say branch1,
branch2 and so on.

Currently i have a jenkins jobs which builds the master or whatever i
specify in job configuration.Now what i wish to achieve is if i commit my
changes to branch 1 , my jenkins job should automatically context switch
from master to branch1 and build that, and in the next step if i commit on
branch2 it should build branch 2.

i am able to make rest calls via DSL script to get the branch names and
then use job dsl to create the jobs as the number of branches are
present.
However i don't want multiple jobs. What i am looking is having a single
intelligent job to do the context switching between jobs.

Any idea or help will be appreciated.

Thanks,
Touseef
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3543d8da-3c80-4764-bc7c-092053f8c103%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mark Waite
2018-10-30 09:30:07 UTC
Permalink
Replies inline
Post by touseef
Hi ,
I have a source code repository having multiple branches say branch1,
branch2 and so on.
Currently i have a jenkins jobs which builds the master or whatever i
specify in job configuration.Now what i wish to achieve is if i commit my
changes to branch 1 , my jenkins job should automatically context switch
from master to branch1 and build that, and in the next step if i commit on
branch2 it should build branch 2.
i am able to make rest calls via DSL script to get the branch names and
then use job dsl to create the jobs as the number of branches are
present.
However i don't want multiple jobs. What i am looking is having a single
intelligent job to do the context switching between jobs.
Can you further explain why you want a "single intelligent job to do the
context switching"?

That is a technique that was used in the past with Jenkins freestyle jobs.
The technique makes it very hard to diagnose the locations of test
failures, or the place where a compilation failure happened, or the
differences from one job to the next.

If you're not using Pipeline jobs, then having a single job which builds
any of several branches is relatively easy (add the branch names to build),
though it will tend to confuse most users.

If you're using Pipeline jobs, you'll likely be much happier with a
multibranch pipeline so that each branch gets its own job and job history
and so that new jobs are created automatically for new branches and are
automatically destroyed for deleted branches.

Mark Waite
Post by touseef
Any idea or help will be appreciated.
Thanks,
Touseef
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/3543d8da-3c80-4764-bc7c-092053f8c103%40googlegroups.com
<https://groups.google.com/d/msgid/jenkinsci-users/3543d8da-3c80-4764-bc7c-092053f8c103%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtHHTJeWtSCsU5gGfCKf-qhH0OH21fGW1gDNteU%2BD4oLvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Ivan Fernandez Calvo
2018-10-30 18:00:38 UTC
Permalink
you need to take a look to multibranch pipelines and blueocean, i think it makes what you want
https://jenkins.io/projects/blueocean/
https://jenkins.io/doc/book/pipeline/multibranch/
https://jenkins.io/doc/tutorials/build-a-multibranch-pipeline-project/
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/37601fdb-8f44-4226-b91f-1e459150d33c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...