Can't set strategy in branchSources using github

956 views
Skip to first unread message

Carlos Tadeu Panato Jr

unread,
Sep 11, 2017, 6:06:48 AM9/11/17
to job-dsl-plugin
Hello

The previous version of the Job DSL I was able to do this:


multibranchPipelineJob("xxx-yyyy") {
  branchSources {
    branchSource {
      source {
        github {
          scanCredentialsId("xxxx")
          checkoutCredentialsId("xxxx")
          apiUri("")
          repoOwner("xxx")
          repository("xx-xxx")
          buildForkPRHead(false)
          buildForkPRMerge(true)
          buildOriginBranch(true)
          buildOriginBranchWithPR(false)
          buildOriginPRHead(false)
          buildOriginPRMerge(true)
        }
      }
      strategy {
        defaultBranchPropertyStrategy {
          props {
            noTriggerBranchProperty()
          }
        }
      }
    }
  }
  orphanedItemStrategy {
    discardOldItems {
      daysToKeep(10)
      numToKeep(1000)
    }
  }
  triggers {
    periodic(1440)
  }
}

However, after the upgrade for 1.65, the branchSource -> source -> github looks like is deprecated and then I need to use the branchSources -> gitHub, but if that I cannot set the defaultBranchPropertyStrategy -> noTriggerBranchProperty

There is a way to set that in the job dsl?

the update code is something like this, I tried to add the strategy but did not work. Also tried the properties -> noTriggerOrganizationFolderProperty with no sucess either.
Any help to get the strategy working again with out downgrade the plugin?

multibranchPipelineJob("xxx-yyy") {
  branchSources {
    github {
      scanCredentialsId("xxxx")
      checkoutCredentialsId("xxx")
      apiUri("")
      repoOwner("xx")
      repository("xx-xx")
      buildForkPRHead(false)
      buildForkPRMerge(true)
      buildOriginBranch(true)
      buildOriginBranchWithPR(false)
      buildOriginPRHead(false)
      buildOriginPRMerge(true)
    }
  }
  orphanedItemStrategy {
    discardOldItems {
      daysToKeep(10)
      numToKeep(1000)
    }
  }
  triggers {
    periodic(1440)
  }
}


thanks so much!

Carlos Tadeu Panato Jr

unread,
Sep 12, 2017, 8:40:07 AM9/12/17
to job-dsl-plugin
I did that, looks not beautiful and I prefer having the job dsl function to behave the same we had before:

multibranchPipelineJob("eeee-eeeee") {
  branchSources {
    github {
      scanCredentialsId("xxxxx")
      checkoutCredentialsId("xxxxx")
      apiUri("")
      repoOwner("xxxx")
      repository("xxx-yyyyyy")
      buildForkPRHead(false)
      buildForkPRMerge(true)
      buildOriginBranch(true)
      buildOriginBranchWithPR(false)
      buildOriginPRHead(false)
      buildOriginPRMerge(true)
    }
  }

  configure { project ->
    project / 'sources' / 'data' / 'jenkins.branch.BranchSource'/ strategy(class: 'jenkins.branch.DefaultBranchPropertyStrategy') {
      properties(class: 'java.util.Arrays$ArrayList') {
        a(class: 'jenkins.branch.BranchProperty-array'){
          'jenkins.branch.NoTriggerBranchProperty'()

Daniel Spilker

unread,
Oct 5, 2017, 3:07:17 PM10/5/17
to job-dsl...@googlegroups.com
The SCM API and Branch API plugins have gone through a redesign and things change a bit (lot). See https://jenkins.io/blog/2017/01/17/scm-api-2/.

See multibranchPipelineJob -> branchSources -> branchSource -> strategy -> defaultBranchPropertyStrategy -> props -> noTriggerBranchProperty in the embedded API viewer for configuring the NoTriggerBranchProperty.

Daniel

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugin+unsubscribe@googlegroups.com.
To post to this group, send email to job-dsl-plugin@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/103ab614-f9ea-430d-97a1-95290173ecf7%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages