Advanced clone behavior caused all branches to build

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Advanced clone behavior caused all branches to build

Sverre Moe-2
Adding Branch Source "Advanced clone behaviors" caused Jenkins to initiate build of ALL my branches.
All I wanted was to make sure the git tags where fetched during checkout.

Takeover for application » master by source #1 from source that no longer exists
Branch reopened: master (ae0617dc2ceea28577b4c73356f705f2d597ae6c)

The branch was never "closed".

After saving the project it performed a Multibranch Pipeline scan. Then it started building almost 300 branches.
It took forever to cancel all those builds.
I ultimately had to remove the advanced clone behavior. Then just add a simple sh "git fetch  --tags --quiet" to my pipeline script.


Desperately need an Kill All jobs in Jenkins. Having 2-300 jobs suddenly triggered is a nightmare.
And because Jenkins will NOT kill the job immediately I need to click like a maniac several times on cancel.
When I mean kill, I mean kill, the consequences be damned.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0f9c45d6-1663-400e-86ce-b0134bb974c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Advanced clone behavior caused all branches to build

Sverre Moe-2
I am not sure if it was the advanced clone behavior that causes this.
Another project that got triggered by notifyCommit URL just started to build ALL branches.

The only other change I have done was to add Discover Tags.

Perhaps it is the way I did it?
I deleted the existing Branch Source and created a new one.
Perhaps that is Why it is rebuilding all branches?

However, if I scan again, it will trigger all branches again. Every time.

import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject
 
import hudson.plugins.git.browser.GitWeb
import hudson.plugins.git.extensions.impl.CloneOption
import jenkins.branch.BranchSource
import jenkins.branch.DefaultBranchPropertyStrategy
import jenkins.plugins.git.GitSCMSource
import jenkins.plugins.git.traits.BranchDiscoveryTrait
import jenkins.plugins.git.traits.CloneOptionTrait
import jenkins.plugins.git.traits.TagDiscoveryTrait
 
 
def jenkinsInstance = jenkins.model.Jenkins.getInstance()
jenkinsInstance
.getView("projects").getItems().each { project ->
   
if (project instanceof WorkflowMultiBranchProject) {
       
def sources = project.getSourcesList()
        sources
.clear()
 
       
def projectName = project.getName()
       
def REMOTE = "ssh://[hidden email]/projects/"+ projectName +".git"
       
GitSCMSource gitSCMSource = new GitSCMSource(null, REMOTE, "c9atdnbtdy1883", "*", "", false)
       
DefaultBranchPropertyStrategy strategy = new DefaultBranchPropertyStrategy(null)
 
       
def url = "http://git.company.com/gitweb/?p=projects/"+projectName+".git"
       
def browser = new GitWeb(url)
        gitSCMSource
.setBrowser(browser)
 
       
def traits = new ArrayList()
 
       
def branchTrait = new BranchDiscoveryTrait()
        traits
.add(branchTrait)
 
       
def tagTrait = new TagDiscoveryTrait()
        traits
.add(tagTrait)
 
       
def cloneOption = new CloneOption(false, false, "", null)
        cloneOption
.setDepth(0)
       
def cloneOptionTrait = new CloneOptionTrait(cloneOption)
        traits
.add(cloneOptionTrait)
 
        gitSCMSource
.setTraits(traits)
 
       
BranchSource branchSource = new BranchSource(gitSCMSource, strategy)
        sources
.add(branchSource)
   
}
}



onsdag 13. juni 2018 13.53.56 UTC+2 skrev Sverre Moe følgende:
Adding Branch Source "Advanced clone behaviors" caused Jenkins to initiate build of ALL my branches.
All I wanted was to make sure the git tags where fetched during checkout.

Takeover for application » master by source #1 from source that no longer exists
Branch reopened: master (ae0617dc2ceea28577b4c73356f705f2d597ae6c)

The branch was never "closed".

After saving the project it performed a Multibranch Pipeline scan. Then it started building almost 300 branches.
It took forever to cancel all those builds.
I ultimately had to remove the advanced clone behavior. Then just add a simple sh "git fetch  --tags --quiet" to my pipeline script.


Desperately need an Kill All jobs in Jenkins. Having 2-300 jobs suddenly triggered is a nightmare.
And because Jenkins will NOT kill the job immediately I need to click like a maniac several times on cancel.
When I mean kill, I mean kill, the consequences be damned.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8cc1545a-93c8-46cc-8032-0bb1d999d919%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Advanced clone behavior caused all branches to build

Sverre Moe-2
It seems more evident now that the reason for all branches gotten triggered was that I scratched the Branch Source configuration and created a new one.
After I let all the branches build (fail and succeed) then scanning again would not trigger a second run.

onsdag 13. juni 2018 14.51.22 UTC+2 skrev Sverre Moe følgende:
I am not sure if it was the advanced clone behavior that causes this.
Another project that got triggered by notifyCommit URL just started to build ALL branches.

The only other change I have done was to add Discover Tags.

Perhaps it is the way I did it?
I deleted the existing Branch Source and created a new one.
Perhaps that is Why it is rebuilding all branches?

However, if I scan again, it will trigger all branches again. Every time.

import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject
 
import hudson.plugins.git.browser.GitWeb
import hudson.plugins.git.extensions.impl.CloneOption
import jenkins.branch.BranchSource
import jenkins.branch.DefaultBranchPropertyStrategy
import jenkins.plugins.git.GitSCMSource
import jenkins.plugins.git.traits.BranchDiscoveryTrait
import jenkins.plugins.git.traits.CloneOptionTrait
import jenkins.plugins.git.traits.TagDiscoveryTrait
 
 
def jenkinsInstance = jenkins.model.Jenkins.getInstance()
jenkinsInstance
.getView("projects").getItems().each { project ->
   
if (project instanceof WorkflowMultiBranchProject) {
       
def sources = project.getSourcesList()
        sources
.clear()
 
       
def projectName = project.getName()
       
def REMOTE = "ssh://<a href="http://git@git.company.com/projects/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fgit%40git.company.com%2Fprojects%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEjYdcPtXpoQSP0r2Bkwnk8PM5hdQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fgit%40git.company.com%2Fprojects%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEjYdcPtXpoQSP0r2Bkwnk8PM5hdQ&#39;;return true;">git@.../projects/"+ projectName +".git"
       
GitSCMSource gitSCMSource = new GitSCMSource(null, REMOTE, "c9atdnbtdy1883", "*", "", false)
       
DefaultBranchPropertyStrategy strategy = new DefaultBranchPropertyStrategy(null)
 
       
def url = "<a href="http://git.company.com/gitweb/?p=projects/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fgit.company.com%2Fgitweb%2F%3Fp%3Dprojects%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFU6e6dTgOnYDvTHjMmfoRyefXLTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fgit.company.com%2Fgitweb%2F%3Fp%3Dprojects%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFU6e6dTgOnYDvTHjMmfoRyefXLTQ&#39;;return true;">http://git.company.com/gitweb/?p=projects/"+projectName+".git"
       
def browser = new GitWeb(url)
        gitSCMSource
.setBrowser(browser)
 
       
def traits = new ArrayList()
 
       
def branchTrait = new BranchDiscoveryTrait()
        traits
.add(branchTrait)
 
       
def tagTrait = new TagDiscoveryTrait()
        traits
.add(tagTrait)
 
       
def cloneOption = new CloneOption(false, false, "", null)
        cloneOption
.setDepth(0)
       
def cloneOptionTrait = new CloneOptionTrait(cloneOption)
        traits
.add(cloneOptionTrait)
 
        gitSCMSource
.setTraits(traits)
 
       
BranchSource branchSource = new BranchSource(gitSCMSource, strategy)
        sources
.add(branchSource)
   
}
}



onsdag 13. juni 2018 13.53.56 UTC+2 skrev Sverre Moe følgende:
Adding Branch Source "Advanced clone behaviors" caused Jenkins to initiate build of ALL my branches.
All I wanted was to make sure the git tags where fetched during checkout.

Takeover for application » master by source #1 from source that no longer exists
Branch reopened: master (ae0617dc2ceea28577b4c73356f705f2d597ae6c)

The branch was never "closed".

After saving the project it performed a Multibranch Pipeline scan. Then it started building almost 300 branches.
It took forever to cancel all those builds.
I ultimately had to remove the advanced clone behavior. Then just add a simple sh "git fetch  --tags --quiet" to my pipeline script.


Desperately need an Kill All jobs in Jenkins. Having 2-300 jobs suddenly triggered is a nightmare.
And because Jenkins will NOT kill the job immediately I need to click like a maniac several times on cancel.
When I mean kill, I mean kill, the consequences be damned.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/fee005a8-68e2-45f8-9afc-e85f2f2ed4c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.