summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorsbussetti <steve.bussetti@gmail.com>2018-12-10 13:29:50 -0500
committersbussetti <steve.bussetti@gmail.com>2018-12-10 13:44:14 -0500
commitcf152d67c77a1d1b873a952162f981974b447248 (patch)
tree93686c116c70fd8c03c18c399bb04f542f7224ea /tests
parent02e85408f027f831ef00cb812ea66ddcdd226170 (diff)
downloadpython-jenkins-job-builder-cf152d67c77a1d1b873a952162f981974b447248.tar.gz
python-jenkins-job-builder-cf152d67c77a1d1b873a952162f981974b447248.tar.xz
python-jenkins-job-builder-cf152d67c77a1d1b873a952162f981974b447248.zip
Adds named branches to property strategy support
My previous submission added support for property strategy: all branches get the same properties. This patch adds support for the second of 2 options, "named branches get different properties", which allows for a default definition of properties + exceptions for individual refspecs based on their literal branch name. Also includes some re-org of the existing prop. strat. support in order to DRY up the code for both. Also adds sphinx.ext.doctest to docs/src/conf.py extensions to allow for running `make doctest` locally. Change-Id: Icd143fe25b1e2d5c8d1e7e8b0650d91f40838043 Signed-off-by: sbussetti <steve.bussetti@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/multibranch/fixtures/scm_github_named_branch_props.xml94
-rw-r--r--tests/multibranch/fixtures/scm_github_named_branch_props.yaml21
2 files changed, 115 insertions, 0 deletions
diff --git a/tests/multibranch/fixtures/scm_github_named_branch_props.xml b/tests/multibranch/fixtures/scm_github_named_branch_props.xml
new file mode 100644
index 00000000..07818a90
--- /dev/null
+++ b/tests/multibranch/fixtures/scm_github_named_branch_props.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="utf-8"?>
+<org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject plugin="workflow-multibranch">
+ <properties/>
+ <views>
+ <hudson.model.AllView>
+ <name>All</name>
+ <filterExecutors>false</filterExecutors>
+ <filterQueue>false</filterQueue>
+ <properties class="hudson.model.View$PropertyList"/>
+ <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../../.."/>
+ </hudson.model.AllView>
+ </views>
+ <viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
+ <folderViews class="jenkins.branch.MultiBranchProjectViewHolder" plugin="branch-api">
+ <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
+ </folderViews>
+ <healthMetrics>
+ <com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric plugin="cloudbees-folder">
+ <nonRecursive>false</nonRecursive>
+ </com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric>
+ </healthMetrics>
+ <icon class="jenkins.branch.MetadataActionFolderIcon" plugin="branch-api">
+ <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
+ </icon>
+ <orphanedItemStrategy class="com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy" plugin="cloudbees-folder">
+ <pruneDeadBranches>true</pruneDeadBranches>
+ <daysToKeep>-1</daysToKeep>
+ <numToKeep>-1</numToKeep>
+ </orphanedItemStrategy>
+ <triggers/>
+ <sources class="jenkins.branch.MultiBranchProject$BranchSourceList" plugin="branch-api">
+ <data>
+ <jenkins.branch.BranchSource>
+ <source class="org.jenkinsci.plugins.github_branch_source.GitHubSCMSource" plugin="github-branch-source">
+ <id>gh-johndoe-foo</id>
+ <repoOwner>johndoe</repoOwner>
+ <repository>foo</repository>
+ <traits>
+ <org.jenkinsci.plugins.github__branch__source.BranchDiscoveryTrait>
+ <strategyId>1</strategyId>
+ </org.jenkinsci.plugins.github__branch__source.BranchDiscoveryTrait>
+ <org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait>
+ <strategyId>1</strategyId>
+ <trust class="org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustContributors"/>
+ </org.jenkinsci.plugins.github__branch__source.ForkPullRequestDiscoveryTrait>
+ <org.jenkinsci.plugins.github__branch__source.OriginPullRequestDiscoveryTrait>
+ <strategyId>1</strategyId>
+ </org.jenkinsci.plugins.github__branch__source.OriginPullRequestDiscoveryTrait>
+ <jenkins.plugins.git.traits.WipeWorkspaceTrait>
+ <extension class="hudson.plugins.git.extensions.impl.WipeWorkspace"/>
+ </jenkins.plugins.git.traits.WipeWorkspaceTrait>
+ </traits>
+ </source>
+ <strategy class="jenkins.branch.NamedExceptionsBranchPropertyStrategy">
+ <defaultProperties class="java.util.Arrays$ArrayList">
+ <a class="jenkins.branch.BranchProperty-array">
+ <org.jenkinsci.plugins.workflow.multibranch.DurabilityHintBranchProperty plugin="workflow-multibranch">
+ <hint>MAX_SURVIVABILITY</hint>
+ </org.jenkinsci.plugins.workflow.multibranch.DurabilityHintBranchProperty>
+ </a>
+ </defaultProperties>
+ <namedExceptions class="java.util.Arrays$ArrayList">
+ <a class="jenkins.branch.NamedExceptionsBranchPropertyStrategy$Named-array">
+ <jenkins.branch.NamedExceptionsBranchPropertyStrategy_-Named>
+ <name>master</name>
+ <props class="java.util.Arrays$ArrayList">
+ <a class="jenkins.branch.BranchProperty-array">
+ <jenkins.branch.NoTriggerBranchProperty/>
+ <org.jenkinsci.plugins.workflow.multibranch.DurabilityHintBranchProperty plugin="workflow-multibranch">
+ <hint>SURVIVABLE_NONATOMIC</hint>
+ </org.jenkinsci.plugins.workflow.multibranch.DurabilityHintBranchProperty>
+ </a>
+ </props>
+ </jenkins.branch.NamedExceptionsBranchPropertyStrategy_-Named>
+ <jenkins.branch.NamedExceptionsBranchPropertyStrategy_-Named>
+ <name>staging</name>
+ <props class="java.util.Arrays$ArrayList">
+ <a class="jenkins.branch.BranchProperty-array">
+ <jenkins.branch.NoTriggerBranchProperty/>
+ </a>
+ </props>
+ </jenkins.branch.NamedExceptionsBranchPropertyStrategy_-Named>
+ </a>
+ </namedExceptions>
+ </strategy>
+ </jenkins.branch.BranchSource>
+ </data>
+ <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
+ </sources>
+ <factory class="org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory">
+ <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
+ <scriptPath>Jenkinsfile</scriptPath>
+ </factory>
+</org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject>
diff --git a/tests/multibranch/fixtures/scm_github_named_branch_props.yaml b/tests/multibranch/fixtures/scm_github_named_branch_props.yaml
new file mode 100644
index 00000000..02390c72
--- /dev/null
+++ b/tests/multibranch/fixtures/scm_github_named_branch_props.yaml
@@ -0,0 +1,21 @@
+name: 'demo-multibranch-github-min'
+project-type: multibranch
+scm:
+ - github:
+ repo: 'foo'
+ repo-owner: 'johndoe'
+
+ property-strategies:
+ named-branches:
+ defaults:
+ - pipeline-branch-durability-override: max-survivability
+ exceptions:
+ - exception:
+ branch-name: master
+ properties:
+ - suppress-scm-triggering: true
+ - pipeline-branch-durability-override: survivable-nonatomic
+ - exception:
+ branch-name: staging
+ properties:
+ - suppress-scm-triggering: true