Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/988 - updated for Upstream/Downstream jenkins master #997

Merged
merged 3 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/s2i/create-containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ if [ -z "${REPO_REF}" ] ; then
else
REPO_REF_PARAM="-p REPO_REF=${REPO_REF}"
fi
##
if [ -z "{MASTER_CONTEXT_DIR}" ]; then
MASTER_CONTEXT_DIR=""
else
MASTER_CONTEXT_DIR="-p MASTER_CONTEXT_DIR=${MASTER_CONTEXT_DIR}"
fi

oc project "${project}" > /dev/null 2>&1
if [ $? -ne 0 ] ; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ objects:
limits:
memory: ${MEMORY_LIMIT}
source:
contextDir: ${CONTEXT_DIR}
contextDir: ${MASTER_CONTEXT_DIR}
git:
uri: ${REPO_URL}
ref: ${REPO_REF}
Expand Down Expand Up @@ -233,8 +233,9 @@ parameters:
name: REPO_REF
value: develop
- description: Path within Git project to build; empty for root project directory.
name: CONTEXT_DIR
value: config/s2i/jenkins/master
name: MASTER_CONTEXT_DIR
required: true
value: config/s2i/jenkins/master-upstream
- name: JENKINS_SERVICE_NAME
displayName: Jenkins Service Name
description: The name of the OpenShift Service exposed for the Jenkins container.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
pipelineJob("ci-linchpin-messageBus-merge") {
definition {
logRotator {
numToKeep(100)
}

concurrentBuild(false)

parameters {
stringParam(
"CI_MESSAGE",
"",
"fedmsg msg"
)
}

triggers {
ciBuildTrigger {
providerData {
fedMsgSubscriberProviderData {
name('fedora-fedmsg')
overrides {
topic('org.centos.prod.ci.linchpin.pr_merge.queued')
}
}
}
noSquash(true)
}
}

cpsScm {
scm {
git {
remote {
url('https://github.com/CentOS-PaaS-SIG/linchpin')
refspec("+refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*")
}
branch('develop')
}
}
scriptPath("config/Dockerfiles/JenkinsfileMessageBusMerge")
lightweight(false)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
pipelineJob("ci-linchpin-messageBus-trigger") {
definition {
logRotator {
numToKeep(100)
}

concurrentBuild(false)

parameters {
stringParam(
"CI_MESSAGE",
"",
"fedmsg msg"
)
}

triggers {
ciBuildTrigger {
providerData {
fedMsgSubscriberProviderData {
name('fedora-fedmsg')
overrides {
topic('org.centos.prod.ci.linchpin.pr.queued')
}
}
}
noSquash(true)
}
}

cpsScm {
scm {
git {
remote {
url('https://github.com/CentOS-PaaS-SIG/linchpin')
refspec("+refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*")
}
branch('develop')
}
}
scriptPath("config/Dockerfiles/JenkinsfileMessageBusTrigger")
lightweight(false)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import com.redhat.jenkins.plugins.ci.messaging.*
import hudson.markup.RawHtmlMarkupFormatter
import hudson.model.*
import hudson.security.*
import javaposse.jobdsl.dsl.DslScriptLoader
import javaposse.jobdsl.plugin.JenkinsJobManagement
import javaposse.jobdsl.plugin.GlobalJobDslSecurityConfiguration
import groovy.io.FileType

def logger = Logger.getLogger("")
logger.info("Disabling CLI over remoting")
Expand Down Expand Up @@ -57,3 +61,16 @@ if ( envVarsNodePropertyList == null || envVarsNodePropertyList.size() == 0 ) {
// for other environments.
envVars.put("DOCKER_REPO_URL", "172.30.1.1:5000")
instance.save()

// Add ci-linchpin-messageBus-* jobs via dsl
env = System.getenv()
logger.info('Disabling job dsl script security')
GlobalConfiguration.all().get(GlobalJobDslSecurityConfiguration.class).useScriptSecurity=false
def dslDir = new File("${env['JENKINS_HOME']}/dsl-jobs")
dslDir.eachFileRecurse (FileType.FILES) { file ->
config = new File(file.path).text
workspace = new File("${env['JENKINS_HOME']}")
jobManagement = new JenkinsJobManagement(System.out, [:], workspace)
new DslScriptLoader(jobManagement).runScript(config)
logger.info('Created jms job: ' + file.path)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.1' encoding='UTF-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<flow-definition plugin="workflow-job@2.21">
<actions>
<org.jenkinsci.plugins.workflow.multibranch.JobPropertyTrackerAction plugin="workflow-multibranch@2.18">
Expand Down Expand Up @@ -91,4 +91,4 @@
</definition>
<triggers/>
<disabled>false</disabled>
</flow-definition>
</flow-definition>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version='1.0' encoding='UTF-8'?>
<hudson.tasks.Maven_-DescriptorImpl>
<installations>
<hudson.tasks.Maven_-MavenInstallation>
<name>M3</name>
<properties>
<hudson.tools.InstallSourceProperty>
<installers>
<hudson.tasks.Maven_-MavenInstaller>
<id>3.3.9</id>
</hudson.tasks.Maven_-MavenInstaller>
</installers>
</hudson.tools.InstallSourceProperty>
</properties>
</hudson.tasks.Maven_-MavenInstallation>
</installations>
</hudson.tasks.Maven_-DescriptorImpl>
76 changes: 76 additions & 0 deletions config/s2i/jenkins/master-upstream/configuration/init.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import java.util.logging.Logger
import jenkins.security.s2m.*
import jenkins.model.*;
import com.redhat.jenkins.plugins.ci.*
import com.redhat.jenkins.plugins.ci.messaging.*
import hudson.markup.RawHtmlMarkupFormatter
import hudson.model.*
import hudson.security.*
import javaposse.jobdsl.dsl.DslScriptLoader
import javaposse.jobdsl.plugin.JenkinsJobManagement
import javaposse.jobdsl.plugin.GlobalJobDslSecurityConfiguration
import groovy.io.FileType

def logger = Logger.getLogger("")
logger.info("Disabling CLI over remoting")
jenkins.CLI.get().setEnabled(false);
logger.info("Enable Slave -> Master Access Control")
Jenkins.instance.injector.getInstance(AdminWhitelistRule.class).setMasterKillSwitch(false);
// Set global and job read permissions
def strategy = Jenkins.instance.getAuthorizationStrategy()
strategy.add(hudson.model.Hudson.READ,'anonymous')
strategy.add(hudson.model.Item.READ,'anonymous')
Jenkins.instance.setAuthorizationStrategy(strategy)
// Set Markup Formatter to Safe HTML so PR hyperlinks work
Jenkins.instance.setMarkupFormatter(new RawHtmlMarkupFormatter(false))
Jenkins.instance.save()

logger.info("Setup fedora-fedmsg Messaging Provider")
FedMsgMessagingProvider fedmsg = new FedMsgMessagingProvider("fedora-fedmsg", "tcp://hub.fedoraproject.org:9940", "tcp://172.19.4.24:9941", "org.fedoraproject");
GlobalCIConfiguration.get().addMessageProvider(fedmsg)

logger.info("Setup fedora-fedmsg-stage Messaging Provider")
FedMsgMessagingProvider fedmsgStage = new FedMsgMessagingProvider("fedora-fedmsg-stage", "tcp://stg.fedoraproject.org:9940", "tcp://172.19.4.36:9941", "org.fedoraproject");
GlobalCIConfiguration.get().addMessageProvider(fedmsgStage)

logger.info("Setup fedora-fedmsg-devel Messaging Provider")
FedMsgMessagingProvider fedmsgDevel = new FedMsgMessagingProvider("fedora-fedmsg-devel", "tcp://fedmsg-relay.continuous-infra.svc:4001", "tcp://fedmsg-relay.continuous-infra.svc:2003", "org.fedoraproject");
GlobalCIConfiguration.get().addMessageProvider(fedmsgDevel)

logger.info("Setting Time Zone to be EST")
System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone', 'America/New_York')

// Add global variable
instance = Jenkins.getInstance()
globalNodeProperties = instance.getGlobalNodeProperties()
envVarsNodePropertyList = globalNodeProperties.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)

newEnvVarsNodeProperty = null
envVars = null

if ( envVarsNodePropertyList == null || envVarsNodePropertyList.size() == 0 ) {
newEnvVarsNodeProperty = new hudson.slaves.EnvironmentVariablesNodeProperty();
globalNodeProperties.add(newEnvVarsNodeProperty)
envVars = newEnvVarsNodeProperty.getEnvVars()
} else {
envVars = envVarsNodePropertyList.get(0).getEnvVars()

}

// This is the default for minishift. You may need to change this
// for other environments.
envVars.put("DOCKER_REPO_URL", "172.30.1.1:5000")
instance.save()

// Add ci-linchpin-messageBus-* jobs via dsl
env = System.getenv()
logger.info('Disabling job dsl script security')
GlobalConfiguration.all().get(GlobalJobDslSecurityConfiguration.class).useScriptSecurity=false
def dslDir = new File("${env['JENKINS_HOME']}/dsl-jobs")
dslDir.eachFileRecurse (FileType.FILES) { file ->
config = new File(file.path).text
workspace = new File("${env['JENKINS_HOME']}")
jobManagement = new JenkinsJobManagement(System.out, [:], workspace)
new DslScriptLoader(jobManagement).runScript(config)
logger.info('Created jms job: ' + file.path)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow-definition plugin="workflow-job@2.21">
<actions>
<org.jenkinsci.plugins.workflow.multibranch.JobPropertyTrackerAction plugin="workflow-multibranch@2.18">
<jobPropertyDescriptors>
<string>org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty</string>
<string>hudson.model.ParametersDefinitionProperty</string>
<string>com.coravy.hudson.plugins.github.GithubProjectProperty</string>
<string>jenkins.model.BuildDiscarderProperty</string>
</jobPropertyDescriptors>
</org.jenkinsci.plugins.workflow.multibranch.JobPropertyTrackerAction>
</actions>
<description>Container Build of LinchPin project</description>
<keepDependencies>false</keepDependencies>
<properties>
<io.fabric8.jenkins.openshiftsync.BuildConfigProjectProperty plugin="openshift-sync@1.0.18">
<uid />
<namespace />
<name />
<resourceVersion />
</io.fabric8.jenkins.openshiftsync.BuildConfigProjectProperty>
<com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@1.28">
<autoRebuild>false</autoRebuild>
<rebuildDisabled>false</rebuildDisabled>
</com.sonyericsson.rebuild.RebuildSettings>
<org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
<triggers>
<jenkins.triggers.ReverseBuildTrigger>
<spec />
<upstreamProjects>cd-linchpin-release</upstreamProjects>
<threshold>
<name>SUCCESS</name>
<ordinal>0</ordinal>
<color>BLUE</color>
<completeBuild>true</completeBuild>
</threshold>
</jenkins.triggers.ReverseBuildTrigger>
</triggers>
</org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
<jenkins.model.BuildDiscarderProperty>
<strategy class="hudson.tasks.LogRotator">
<daysToKeep>90</daysToKeep>
<numToKeep>30</numToKeep>
<artifactDaysToKeep>30</artifactDaysToKeep>
<artifactNumToKeep>15</artifactNumToKeep>
</strategy>
</jenkins.model.BuildDiscarderProperty>
<com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.29.0">
<displayName />
</com.coravy.hudson.plugins.github.GithubProjectProperty>
<org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty />
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<hudson.model.StringParameterDefinition>
<name>CONTAINER_NAMESPACE</name>
<description>Namespace where container resides</description>
<defaultValue>contrainfra</defaultValue>
<trim>false</trim>
</hudson.model.StringParameterDefinition>
<hudson.model.StringParameterDefinition>
<name>CONTAINER_REGISTRY</name>
<description>Container Registry</description>
<trim>false</trim>
</hudson.model.StringParameterDefinition>
<hudson.model.StringParameterDefinition>
<name>INSTALL_LOCATION</name>
<description>Installation Source. '.' uses the GIT_URL/GIT_BRANCH, 'linchpin' uses pypi.</description>
<defaultValue>linchpin</defaultValue>
<trim>false</trim>
</hudson.model.StringParameterDefinition>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
</properties>
<definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@2.53">
<scm class="hudson.plugins.git.GitSCM" plugin="git@3.9.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>https://github.com/CentOS-PaaS-SIG/linchpin.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>develop</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list" />
<extensions />
</scm>
<scriptPath>config/Dockerfiles/JenkinsfileBuilder</scriptPath>
<lightweight>false</lightweight>
</definition>
<triggers />
<disabled>false</disabled>
</flow-definition>
Loading