Greetings,
I set up the GitHub branch source plugin programmatically with a groovy
script so that when Jenkins docker container image is started the github
branch source plugin is already configured (see attachment for details
L52-67). Currently we are using version 2.0.8. We tried to update to
2.2.3, but had some issues with the plugin working.
This is the warning message we see for this plugin on the updates page:
Warning: the new version of this plugin claims to use a different settings
format than the installed version. Jobs using this plugin may need to be
reconfigured, and/or you may not be able to cleanly revert to the prior
version without manually restoring old settings. Consult the plugin release
notes for details.
In version 2.2.3 a lot of the parameters we were using cannot be used. In
fact the source code for the plugin has those deprecated and restricted
since 2.2.0 as well as with a DoNotUse.class. I noticed that we could
create an object and create the traits array list that way, but how would
we pass that along in the xml since the only parameter of the
GitHubScmNavigator is the repoOwner? I couldn’t find any documentation on
how to do this, so figured I would reach out and see if there’s a
recommended way to do this.
Thanks for your time,
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/792ef209-1067-42ac-a0b4-aa191b23d06d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
import java.io.*
import java.nio.charset.StandardCharsets
import javax.xml.transform.stream.*
def env = System.getenv()
def inst = Jenkins.getInstance()
def scan_orgs = env['GITHUB_SCAN_ORGS'].tokenize(',')
def scan_interval = env['GITHUB_SCAN_INTERVAL'] ?: '28800000'
def repo_specifier = (env['GITHUB_SCAN_REPOS'] == null) ? '.*' :
env['GITHUB_SCAN_REPOS']
def branch_specifier = (env['GITHUB_SCAN_BRANCHES'] == null) ? '.*' :
env['GITHUB_SCAN_BRANCHES']
def ignore_prs = (env['GITHUB_IGNORE_PRS'] == 'true') ? false : true
for ( org in scan_orgs ) {
config = """
<jenkins.branch.OrganizationFolder plugin="[email protected]">
<description></description>
<properties>
<org.jenkinsci.plugins.pipeline.modeldefinition.config.FolderConfig
plugin="[email protected]">
<dockerLabel></dockerLabel>
<registry plugin="[email protected]"/>
</org.jenkinsci.plugins.pipeline.modeldefinition.config.FolderConfig>
<jenkins.branch.NoTriggerOrganizationFolderProperty>
<branches>.*</branches>
</jenkins.branch.NoTriggerOrganizationFolderProperty>
</properties>
<folderViews class="jenkins.branch.OrganizationFolderViewHolder">
<owner reference="../.."/>
</folderViews>
<healthMetrics>
<com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric
plugin="[email protected]">
<nonRecursive>false</nonRecursive>
</com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric>
</healthMetrics>
<icon class="jenkins.branch.MetadataActionFolderIcon">
<owner class="jenkins.branch.OrganizationFolder" reference="../.."/>
</icon>
<orphanedItemStrategy
class="com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy"
plugin="[email protected]">
<pruneDeadBranches>true</pruneDeadBranches>
<daysToKeep>0</daysToKeep>
<numToKeep>0</numToKeep>
</orphanedItemStrategy>
<triggers>
<com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger
plugin="[email protected]">
<spec>H H * * *</spec>
<interval>${scan_interval}</interval>
</com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger>
</triggers>
<navigators>
<org.jenkinsci.plugins.github__branch__source.GitHubSCMNavigator
plugin="[email protected]">
<repoOwner>${org}</repoOwner>
<scanCredentialsId>companyxyz_github_credentials</scanCredentialsId>
<checkoutCredentialsId>SAME</checkoutCredentialsId>
<apiUri>https://github.companyxyz.com/api/v3/</apiUri>
<pattern>${repo_specifier}</pattern>
<includes>${branch_specifier}</includes>
<buildOriginBranch>true</buildOriginBranch>
<buildOriginBranchWithPR>${ignore_prs}</buildOriginBranchWithPR>
<buildOriginPRMerge>false</buildOriginPRMerge>
<buildOriginPRHead>false</buildOriginPRHead>
<buildForkPRMerge>${ignore_prs}</buildForkPRMerge>
<buildForkPRHead>false</buildForkPRHead>
</org.jenkinsci.plugins.github__branch__source.GitHubSCMNavigator>
</navigators>
<projectFactories>
<org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProjectFactory
plugin="[email protected]">
<scriptPath>Jenkinsfile</scriptPath>
</org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProjectFactory>
</projectFactories>
</jenkins.branch.OrganizationFolder>"""
InputStream stream = new
ByteArrayInputStream(config.getBytes(StandardCharsets.UTF_8));
job = inst.getItemByFullName(org, AbstractItem)
if (job == null) {
inst.createProjectFromXML(org, stream);
}
else {
job.updateByXml(new StreamSource(stream));
job.save();
}
}
if(env['MESOS_INSTANCE'] != null) {
def globalProperties = inst.getGlobalNodeProperties()
def newProperty = new hudson.slaves.EnvironmentVariablesNodeProperty();
globalProperties.add(newProperty)
property = newProperty.getEnvVars()
property.put("mesos_instance", env['MESOS_INSTANCE'])
}
inst.save()