[Q] "Scan Repository Now" via api

264 views
Skip to first unread message

Budding Mechanic

unread,
Aug 4, 2017, 12:46:01 PM8/4/17
to Jenkins Users
Hi,

I'm using the multibranch pipeline to scan a git repo for branches.

From the web interface, there's a "Scan Repository Now" button to scan an git org and pick up new folders/branches.  It works fine.

What I'd like to do is programmatically scan a git repo via a groovy script.

I have been unable to find the api call that just scans the repo.

I can use 'scheduleBuild(0)' to do the scanning but it also kicks off a build which I would like to avoid.

Thoughts?

Stephen Connolly

unread,
Aug 5, 2017, 7:58:24 AM8/5/17
to jenkins...@googlegroups.com
Scan repository now will always kick off builds of branches that have changes since the last scan where those changes were missed by the event handler... so you are kind of asking for the non-possible

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ca61e0d0-a97a-4d4f-8d34-c4f7d64a65b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Connolly

unread,
Aug 5, 2017, 7:58:51 AM8/5/17
to jenkins...@googlegroups.com
`scheduleBuild(0)` on the multibranch project is the api for scanning now (as a build of a multibranch project is a scan)

Budding Mechanic

unread,
Aug 5, 2017, 1:00:56 PM8/5/17
to Jenkins Users
So if Jenkins is restarted and scheduleBuild(0) is called during startup, the scan will occur for the org and all builds will start.  

But technically, the only branches that will actually build are the ones in which the SHA changed since the last successful build? eg. while Jenkins was down, a commit occurred.  Is that true?

Otherwise, it seems, a restart with scheduleBuild(0) would kickoff potentially dozens of jobs that have already been built, when I really only want it to scan, pick up new folders or commits and build those.

Can you clarify?

Thanks.


On Saturday, August 5, 2017 at 7:58:51 AM UTC-4, Stephen Connolly wrote:
`scheduleBuild(0)` on the multibranch project is the api for scanning now (as a build of a multibranch project is a scan)
On 5 August 2017 at 04:57, Stephen Connolly <stephen.al...@gmail.com> wrote:
Scan repository now will always kick off builds of branches that have changes since the last scan where those changes were missed by the event handler... so you are kind of asking for the non-possible
On 4 August 2017 at 06:13, Budding Mechanic <budding....@gmail.com> wrote:
Hi,

I'm using the multibranch pipeline to scan a git repo for branches.

From the web interface, there's a "Scan Repository Now" button to scan an git org and pick up new folders/branches.  It works fine.

What I'd like to do is programmatically scan a git repo via a groovy script.

I have been unable to find the api call that just scans the repo.

I can use 'scheduleBuild(0)' to do the scanning but it also kicks off a build which I would like to avoid.

Thoughts?

--
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-use...@googlegroups.com.

Stephen Connolly

unread,
Aug 5, 2017, 1:05:35 PM8/5/17
to jenkins...@googlegroups.com
On Sat 5 Aug 2017 at 18:00, Budding Mechanic <budding....@gmail.com> wrote:
So if Jenkins is restarted and scheduleBuild(0) is called during startup, the scan will occur for the org and all builds will start.  

But technically, the only branches that will actually build are the ones in which the SHA changed since the last successful build? eg. while Jenkins was down, a commit occurred.  Is that true?

Only branches which have changes since the last build will be triggered...

Now if you are discovering pull requests and have asked for merge commits then those may be rebuilt if either the head or the baseline have changed... events will only trigger on head changes not on baseline changes, so in general a scan will typically trigger rebuilds of PR-merge branches... though this is generally what you want if you want the commit status to be accurate 

Otherwise, it seems, a restart with scheduleBuild(0) would kickoff potentially dozens of jobs that have already been built, when I really only want it to scan, pick up new folders or commits and build those.

Can you clarify?

Thanks.


On Saturday, August 5, 2017 at 7:58:51 AM UTC-4, Stephen Connolly wrote:
`scheduleBuild(0)` on the multibranch project is the api for scanning now (as a build of a multibranch project is a scan)
On 5 August 2017 at 04:57, Stephen Connolly <stephen.al...@gmail.com> wrote:
Scan repository now will always kick off builds of branches that have changes since the last scan where those changes were missed by the event handler... so you are kind of asking for the non-possible
On 4 August 2017 at 06:13, Budding Mechanic <budding....@gmail.com> wrote:
Hi,

I'm using the multibranch pipeline to scan a git repo for branches.

From the web interface, there's a "Scan Repository Now" button to scan an git org and pick up new folders/branches.  It works fine.

What I'd like to do is programmatically scan a git repo via a groovy script.

I have been unable to find the api call that just scans the repo.

I can use 'scheduleBuild(0)' to do the scanning but it also kicks off a build which I would like to avoid.

Thoughts?

--
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-use...@googlegroups.com.

--
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-use...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Sent from my phone

Chaitanya Bapat

unread,
Mar 7, 2020, 10:50:59 PM3/7/20
to Jenkins Users
Jumping in late. But can you explain what is mean't by a PR-merge branch?
I googled to find nothing specific to defining what a PR-merge branch is? Is this a Jenkins specific lingo or Git lingo?

On Saturday, 5 August 2017 10:05:35 UTC-7, Stephen Connolly wrote:

To unsubscribe from this group and stop receiving emails from it, send an email to jenkins...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages