Initial JJB bootstrap

Load in the initial JJB configuration.

Change-Id: Ic590d788a6b7dea78acc5d9b259d673f1f27b930
Signed-off-by: Linux Foundation Administrators <collab-it+onlab@linuxfoundation.org>
diff --git a/.coafile b/.coafile
new file mode 100644
index 0000000..3f6f8f4
--- /dev/null
+++ b/.coafile
@@ -0,0 +1,33 @@
+[GitCommit]
+bears = GitCommitBear
+ignore_length_regex = Signed-off-by,
+    Also-by,
+    Co-authored-by,
+    http://,
+    https://
+
+[JSON]
+bears = JSONFormatBear
+files = **/*.json
+ignore = .*/**
+indent_size = 2
+
+[YAML]
+bears = YAMLLintBear
+files = jjb/**/*.yaml
+document_start = True
+yamllint_config = yamllint.conf
+
+[ShellCheck]
+bears = ShellCheckBear,SpaceConsistencyBear
+files = jenkins-scripts/**/*.sh,
+    jjb/**/*.sh,
+    scripts/**/*.sh
+ignore = jenkins-scripts/*-local-env.sh,
+    jjb/global-jjb/shell/*.sh,
+    jjb/include-docker-push.sh,
+    jjb/include-update-pom-versions.sh,
+    jjb/testsuite/testsuite-docker.sh,
+shell = bash
+indent_size = 4
+use_spaces = yeah
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..5eb4e67
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,25 @@
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+indent_style = space
+
+[*.json]
+indent_size = 2
+
+[*.rst]
+indent_size = 4
+
+[*.markdown]
+indent_size = 4
+max_line_length = 80
+
+[*.sh]
+indent_size = 4
+max_line_length = 80
+
+[*.yaml]
+indent_size = 4
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..11b529f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,32 @@
+# Ignore Mac temp files
+.DS_Store
+
+# Ignore Vim temporary files
+.*.sw?
+
+# Ignore changes to the JJB Configuration File
+jenkins.ini
+
+# We don't want .netrc files since they're credential files
+.netrc
+
+# Maven
+target/
+
+# Vagrant
+.vagrant
+
+# IntelliJ
+.idea/
+*.iml
+
+# Eclipse
+.project
+/.pydevproject
+
+# Python
+.tox/
+__pycache__/
+*.pyc
+
+onap_sandbox
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..bffd428
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "jjb/global-jjb"]
+	path = jjb/global-jjb
+	url = https://github.com/lfit/releng-global-jjb.git
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..1633664
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,4 @@
+[gerrit]
+host=gerrit.onosproject.org
+port=29418
+project=ci-management.git
diff --git a/jenkins-scripts/README b/jenkins-scripts/README
new file mode 100644
index 0000000..63a49a6
--- /dev/null
+++ b/jenkins-scripts/README
@@ -0,0 +1,8 @@
+The scripts in this directory are used by the Jenkins spin-up component
+for dynamic minions.
+
+The spinup script will be as follows (${system_type} will be replaced
+with the appropriate system_type script)
+
+git clone https://github.com/edgexfoundry/ci-management.git /ci-management
+/ci-management/jenkins-scripts/jenkins-init-script.sh
diff --git a/jenkins-scripts/basic_settings.sh b/jenkins-scripts/basic_settings.sh
new file mode 100755
index 0000000..bf0eea0
--- /dev/null
+++ b/jenkins-scripts/basic_settings.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2016 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+case "$(facter operatingsystem)" in
+  Ubuntu)
+    apt-get update
+    ;;
+  *)
+    # Do nothing on other distros for now
+    ;;
+esac
+
+IPADDR=$(facter ipaddress)
+HOSTNAME=$(facter hostname)
+FQDN=$(facter fqdn)
+
+echo "${IPADDR} ${HOSTNAME} ${FQDN}" >> /etc/hosts
+
+#Increase limits
+cat <<EOF > /etc/security/limits.d/jenkins.conf
+jenkins         soft    nofile          16000
+jenkins         hard    nofile          16000
+EOF
+
+cat <<EOSSH >> /etc/ssh/ssh_config
+Host *
+  ServerAliveInterval 60
+
+# we don't want to do SSH host key checking on spin-up systems
+Host 10.30.122.*
+  StrictHostKeyChecking no
+  UserKnownHostsFile /dev/null
+EOSSH
+
+cat <<EOKNOWN >  /etc/ssh/ssh_known_hosts
+github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
+EOKNOWN
+
+# vim: sw=2 ts=2 sts=2 et :
diff --git a/jenkins-scripts/create_jenkins_user.sh b/jenkins-scripts/create_jenkins_user.sh
new file mode 100755
index 0000000..86a5c92
--- /dev/null
+++ b/jenkins-scripts/create_jenkins_user.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2016 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+#######################
+# Create Jenkins User #
+#######################
+
+OS=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
+
+useradd -m -s /bin/bash jenkins
+
+# Check if docker group exists
+grep -q docker /etc/group
+if [ "$?" == '0' ]
+then
+  # Add jenkins user to docker group
+  usermod -a -G docker jenkins
+fi
+
+# Check if mock group exists
+grep -q mock /etc/group
+if [ "$?" == '0' ]
+then
+  # Add jenkins user to mock group so they can build Int/Pack's RPMs
+  usermod -a -G mock jenkins
+fi
+
+mkdir /home/jenkins/.ssh
+mkdir /w
+cp -r /home/${OS}/.ssh/authorized_keys /home/jenkins/.ssh/authorized_keys
+# Generate ssh key for use by Robot jobs
+echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa
+chown -R jenkins:jenkins /home/jenkins/.ssh /w
diff --git a/jenkins-scripts/jenkins-init-script.sh b/jenkins-scripts/jenkins-init-script.sh
new file mode 100755
index 0000000..67987b5
--- /dev/null
+++ b/jenkins-scripts/jenkins-init-script.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2016 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+# vim: ts=4 sw=4 sts=4 et :
+
+cd /ci-management/jenkins-scripts
+chmod +x ./*.sh
+./system_type.sh
+
+source /tmp/system_type.sh
+./basic_settings.sh
+if [ -f "${SYSTEM_TYPE}.sh" ]
+then
+    ./"${SYSTEM_TYPE}.sh"
+fi
+
+# Create the jenkins user last so that hopefully we don't have to deal with
+# guard files
+./create_jenkins_user.sh
diff --git a/jenkins-scripts/system_type.sh b/jenkins-scripts/system_type.sh
new file mode 100755
index 0000000..9aeea20
--- /dev/null
+++ b/jenkins-scripts/system_type.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2016 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+HOST=$(/bin/hostname)
+SYSTEM_TYPE=''
+
+IFS=','
+for i in "basebuild,basebuild" \
+         "centos,centos" \
+         "trusty,trusty" \
+         "xenial,xenial"
+do set -- $i
+    if [[ $HOST == *"$1"* ]]; then
+        SYSTEM_TYPE="$2"
+        break
+    fi
+done
+
+# Write out the system type to an environment file to then be sourced
+echo "SYSTEM_TYPE=${SYSTEM_TYPE}" > /tmp/system_type.sh
+
+# vim: sw=4 ts=4 sts=4 et :
diff --git a/jenkins.ini.example b/jenkins.ini.example
new file mode 100644
index 0000000..959f06b
--- /dev/null
+++ b/jenkins.ini.example
@@ -0,0 +1,13 @@
+[job_builder]
+ignore_cache=True
+keep_descriptions=False
+include_path=.:scripts:~/git/
+recursive=True
+
+[jenkins]
+query_plugins_info=False
+#user=jenkins
+#password=1234567890abcdef1234567890abcdef
+url=http://localhost:8080
+##### This is deprecated, use job_builder section instead
+#ignore_cache=True
diff --git a/jjb/ci-management/ci-management.yaml b/jjb/ci-management/ci-management.yaml
new file mode 100644
index 0000000..6bb4fea
--- /dev/null
+++ b/jjb/ci-management/ci-management.yaml
@@ -0,0 +1,18 @@
+---
+- project:
+    archive-artifacts: '**/*.log'
+    branch: 'master'
+    build-timeout: '60'
+    build-node: 'centos7-basebuild-1c-1g'
+
+    jobs:
+      - '{project-name}-ci-jobs'
+      - '{project-name}-packer-jobs':
+          platforms:
+            - centos
+          templates:
+            - basebuild
+
+    name: ci-management-jobs
+    project: 'ci-management'
+    project-name: 'ci-management'
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
new file mode 100644
index 0000000..d1aa53c
--- /dev/null
+++ b/jjb/defaults.yaml
@@ -0,0 +1,40 @@
+---
+# GLOBAL jenkins defaults
+
+- defaults:
+    name: global
+
+    # lftools
+    lftools-version: <1.0.0
+
+    # lf-infra-defaults
+    jenkins-ssh-credential: 'onos-jenkins-ssh'
+
+    # build discards
+    build-days-to-keep: 30
+
+    # Timeout in minutes
+    build-timeout: 360
+    build-node: centos7-basebuild-1c-1g
+
+    # default gerrit server definition
+    server-name: 'ONOS Project Gerrit'
+    gerrit-server-name: 'ONOS Project Gerrit'
+
+    archive-artifacts: ''
+
+    # Set default maven version used for everything
+    mvn-version: 'mvn33'
+
+    # Default maven goals
+    mvn-goals: 'clean install'
+    mvn-opts: ''
+
+    # Maven / Java
+    edgex-infra-mvn-opts: |
+        --show-version
+        --batch-mode
+        -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
+        -Djenkins
+        -Dmaven.repo.local=/tmp/r
+        -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r
diff --git a/jjb/global-jjb b/jjb/global-jjb
new file mode 160000
index 0000000..4e494e6
--- /dev/null
+++ b/jjb/global-jjb
@@ -0,0 +1 @@
+Subproject commit 4e494e6bf70108968f052cd4ce1d8379fee04a43
diff --git a/scripts/.gitignore b/scripts/.gitignore
new file mode 100644
index 0000000..c5ec4a4
--- /dev/null
+++ b/scripts/.gitignore
@@ -0,0 +1,7 @@
+# Python
+__pycache__/
+*.pyc
+
+# ODL Signer
+.sign-artifacts
+gpg-signatures
diff --git a/scripts/check-unicode.sh b/scripts/check-unicode.sh
new file mode 100755
index 0000000..931c99f
--- /dev/null
+++ b/scripts/check-unicode.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2015 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#   Thanh Ha (The Linux Foundation) - Initial implementation
+##############################################################################
+
+directory=${1:-"."}
+
+echo "Scanning $directory"
+if LC_ALL=C grep -r '[^[:print:][:space:]]' "$directory"; then
+    echo "Found files containing non-ascii characters."
+    exit 1
+fi
+
+echo "All files are ASCII only"
+
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..dbeedd8
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,21 @@
+[tox]
+minversion = 1.6
+envlist = coala,docs,pep8
+skipsdist = true
+
+[testenv:coala]
+basepython = python3
+deps =
+    coala
+    coala-bears
+commands =
+    python3 -m nltk.downloader punkt maxent_treebank_pos_tagger averaged_perceptron_tagger
+    coala --non-interactive
+
+# [testenv:docs]
+# deps = sphinx
+# commands = sphinx-build -b html -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/html
+
+[testenv:pep8]
+deps = flake8
+commands = flake8 scripts/
diff --git a/yamllint.conf b/yamllint.conf
new file mode 100644
index 0000000..32d76ab
--- /dev/null
+++ b/yamllint.conf
@@ -0,0 +1,8 @@
+extends: default
+
+rules:
+  empty-lines:
+    max-end: 1
+  line-length:
+    max: 120
+