/jenkins/build_cluster/*pyc
/jenkins/build_cluster/.*sw?
-
+/maintenance-ci/output
+/maintenance-ci/.tox
--- /dev/null
+
+heat_template_version: 2017-09-01
+
+parameters:
+ key_name:
+ type: string
+ description: Name of keypair to assign to servers
+ default: maintenance-ci-public-key
+ image:
+ type: string
+ description: Name of image to use for servers
+ default: xenial-server-cloudimg-amd64-qcow
+ flavor:
+ type: string
+ description: Flavor to use for servers
+ private_net:
+ type: string
+ description: >
+ ID or name of public network for which floating IP addresses will be allocated
+ default: maintenance-ci-network
+ private_subnet:
+ type: string
+ default: maintenance-ci-subnet
+ description: Id of the private sub network for the compute server
+ public_net:
+ type: string
+ default: public
+ description: Id of the public network for the compute server
+ jenkins_labels:
+ type: string
+ default: ''
+ description: List of labels for jenkins swarm agent separated by whitespace
+
+resources:
+
+ public_port:
+ type: OS::Neutron::Port
+ properties:
+ network_id: { get_param: private_net }
+ fixed_ips:
+ - subnet_id: { get_param: private_subnet }
+ security_groups:
+ - dc56d304-e75e-437a-8ef5-656f9bfcd2a0
+
+ floating_ip:
+ type: OS::Neutron::FloatingIP
+ properties:
+ floating_network_id: { get_param: public_net }
+ port_id: { get_resource: public_port }
+
+ jenkins-slave:
+ type: OS::Nova::Server
+ properties:
+ image: { get_param: image }
+ flavor: { get_param: flavor }
+ key_name: { get_param: key_name }
+ networks:
+ - port: { get_resource: public_port }
+ user_data:
+ str_replace:
+ template: |
+ #!/bin/bash
+ mkdir -p /etc/jenkins-agent/
+ echo "$FLAVOR $LABELS" > /etc/jenkins-agent/labels
+ echo "127.0.0.1 $(hostname)" >> /etc/hosts
+ params:
+ $FLAVOR: {get_param: flavor}
+ $LABELS: {get_param: jenkins_labels}
+
+outputs:
+ floating_ip:
+ description: Floating IP
+ value: { get_attr: [ floating_ip, floating_ip_address ] }
--- /dev/null
+- job:
+ name: 'delete-heat-stack'
+ description: |
+ Delete given heat stack on internal cloud from maintenance-team tenant
+
+ concurrent: false
+ node: 'jenkins-master'
+
+ parameters:
+ - string:
+ name: STACK_NAME
+ default: ""
+ description: |
+ Full name of pending for deletion stack.
+ If not given - STACK_PREFIX will be proceed
+ - string:
+ name: STACK_PREFIX
+ description: |
+ All stacks named with prefix on name's start will be deleted.
+ Used only if STACK_NAME is not defined
+ default: ""
+ - string:
+ name: OPENSTACK_CLIENTS_VENV
+ default: /home/jenkins/venv-openstack-clients
+ description: Path to venv with openstack clients inside
+
+
+ wrappers:
+ - timestamps
+ - openstack-creds
+ - timeout:
+ fail: true
+ timeout: 30
+
+ builders:
+ - shell:
+ !include-raw: common/scripts/delete_heat_stack.sh
--- /dev/null
+- job:
+ name: 'deploy-heat-stack'
+ description: |
+ Create given heat stack on internal cloud in maintenance-team tenant
+
+ concurrent: false
+ node: 'jenkins-master'
+
+ parameters:
+ - string:
+ name: HEAT_STACK_YAML
+ description: "Stack yaml file"
+ default: "maintenance-ci/common/data/base_heat.yml"
+ - string:
+ name: STACK_PREFIX
+ description: "Stack prefix"
+ default: "swarm-slave"
+ - string:
+ name: FLAVOR_NAME
+ default: "dev.share"
+ - string:
+ name: IMAGE_NAME
+ default: xenial-server-cloudimg-amd64-qcow
+ - string:
+ name: JENKINS_LABELS
+ default: ''
+ - string:
+ name: OPENSTACK_CLIENTS_VENV
+ default: /home/jenkins/venv-openstack-clients
+ description: Path to venv with openstack clients inside
+
+ scm:
+ - git:
+ url: 'https://review.fuel-infra.org/tools/sustaining/'
+ branches:
+ - origin/master
+
+ wrappers:
+ - timestamps
+ - openstack-creds
+ - timeout:
+ fail: true
+ timeout: 30
+
+ builders:
+ - shell:
+ !include-raw: common/scripts/deploy_heat_stack.sh
--- /dev/null
+- job:
+ name: 'update-jenkins-jobs'
+ description: |
+ <p>Update jenkins jobs configuration</p>
+ <p>Requires python-tox package and user credentials stored as JJB_USER and JJB_PASS using Jenkins Global Passwords feature</p>
+
+
+ concurrent: false
+ node: 'jenkins-master'
+
+ parameters:
+ - string:
+ name: JOBS_LIST
+ description: 'Space separated list of jobs to update. Will update all jobs if empty'
+
+ scm:
+ - git:
+ remotes:
+ - gerrit:
+ url: 'https://review.fuel-infra.org/tools/sustaining/'
+ branches:
+ - master
+ choosing-strategy: default
+
+# triggers:
+# - timed: 'H * * * *'
+# - gerrit:
+# trigger-on:
+# - change-merged-event
+# projects:
+# - project-compare-type: PLAIN
+# project-pattern: 'fuel-infra/jenkins-jobs'
+# branches:
+# - branch-compare-type: PLAIN
+# branch-pattern: 'master'
+# file-paths:
+# - compare-type: ANT
+# pattern: 'common/**'
+# - compare-type: ANT
+# pattern: 'servers/{ci-name}/**'
+
+ wrappers:
+ - timestamps
+ - credentials-binding:
+ - username-password-separated:
+ credential-id: maintenance-ci-robot-password
+ username: JJB_USER
+ password: JJB_PASS
+ - timeout:
+ fail: true
+ timeout: 30
+
+ builders:
+ - shell:
+ !include-raw-escape: common/scripts/update-jenkins-jobs.sh
+
+ publishers:
+ - post-tasks:
+ - matches:
+ - log-text: '.'
+ escalate-status: true
+ script: !include-raw-escape: common/scripts/update-jenkins-cleanup.sh
\ No newline at end of file
--- /dev/null
+- wrapper:
+ name: openstack-creds
+ wrappers:
+ - credentials-binding:
+ - file:
+ credential-id: maintenance-ci-openrc-password-free
+ variable: OPENRC_FILE
+ - username-password-separated:
+ credential-id: maintenance-ci-robot-password
+ username: OS_USERNAME
+ password: OS_PASSWORD
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+set -ex
+
+if [ ! -d "${OPENSTACK_CLIENTS_VENV}" ] ; then
+ virtualenv "${OPENSTACK_CLIENTS_VENV}"
+ source "${OPENSTACK_CLIENTS_VENV}"/bin/activate
+ pip install openstackclient
+ deactivate
+fi
+
+source "${OPENSTACK_CLIENTS_VENV}"/bin/activate
+ source "${OPENRC_FILE?}"
+
+ if [ -z "${STACK_NAME}" ] ; then
+ openstack stack delete -y "${STACK_NAME}"
+ elif [ -z "${STACK_PREFIX}" ] ; then
+ for stack in $(openstack stack list -c 'Stack Name' -f value) ; do
+ if [[ ${stack} == ${STACK_PREFIX}* ]] ; then
+ openstack stack delete -y "${stack}"
+ fi
+ done
+ fi
+deactivate
--- /dev/null
+#!/bin/bash
+
+set -ex
+
+if [ ! -d "${OPENSTACK_CLIENTS_VENV}" ] ; then
+ virtualenv "${OPENSTACK_CLIENTS_VENV}"
+ source "${OPENSTACK_CLIENTS_VENV}"/bin/activate
+ pip install openstackclient
+ deactivate
+fi
+
+
+parameter_string=''
+if [ -z ${IMAGE_NAME} ] ; then
+ parameter_string="${parameter_string} --parameter 'image=${IMAGE_NAME}'"
+fi
+if [ -z ${FLAVOR_NAME} ] ; then
+ parameter_string="${parameter_string} --parameter 'flavor=${FLAVOR_NAME}'"
+fi
+if [ -z ${JENKINS_LABELS} ] ; then
+ parameter_string="${parameter_string} --parameter 'jenkins_labels=${JENKINS_LABELS}'"
+fi
+
+# MAC OS compatibility, for manual usage
+if [ $(which md5sum) ] ; then
+ md5_cmd="md5sum"
+else
+ md5_cmd="md5"
+fi
+
+STACK_NAME="${STACK_PREFIX:-swarm_slave}_$(date +%s | "${md5_cmd}" | head -c 4)"
+
+source "${OPENSTACK_CLIENTS_VENV}"/bin/activate
+ source "${OPENRC_FILE?}"
+ openstack stack create -t "${HEAT_STACK_YAML}" "${STACK_NAME}"
+deactivate
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+set -ex
+
+rm "${WORKSPACE}/../tmp/${JOB_NAME}/jenkins_jobs.ini"
--- /dev/null
+#!/bin/bash
+set -ex
+
+tox --help || apt-get install -y python-tox
+tox -e jobs
+
+source ".tox/jobs/bin/activate"
+
+CONFIG_PATH="${WORKSPACE}/../tmp/${JOB_NAME}"
+# JOBS_LIST - Jenkins string parameter. Space separated list of job names to update.
+# Will update all jobs if empty. Example: verify-mos-docs docker-rebuild-fuel-ci
+JOBS_LIST=(${JOBS_LIST})
+
+umask 0077
+mkdir -p "${CONFIG_PATH}"
+cat > "${CONFIG_PATH}/jenkins_jobs.ini" << EOF
+[jenkins]
+user=${JJB_USER}
+password=${JJB_PASS}
+url=${JENKINS_URL}
+query_plugins_info=False
+[job_builder]
+ignore_cache=True
+recursive=True
+[__future__]
+param_order_from_yaml=true
+EOF
+
+jenkins-jobs --conf "${CONFIG_PATH}/jenkins_jobs.ini" update "common:mos:mcp" "${JOBS_LIST[@]}"
--- /dev/null
+#!/bin/bash
+#
+# :mod:`update-jenkins-views` -- Updating jenkins views
+# =====================================================
+#
+# .. module:: sample-bash-script
+# :platform: Unix, Windows
+# :synopsis: Update views on Jenkins envs
+# .. vesionadded:: MOS-10.0
+# .. vesionchanged:: MOS-10.0
+# .. author:: Artur Mihura <amihura@mirantis.com>
+#
+#
+# This script is used to update views on jenkins environments using
+# jenkins-view-builder and YAML files with view descriptions
+#
+# .. envvar::
+# :var CI_NAME: Id of Jenkins build under which this
+# script is running, defaults to ``0``
+# :type CI_NAME: string
+# :var VIEWS_LIST: Space separated list of view YAMLS to update.
+# Will update all views if empty
+# :type VIEWS_LIST: string
+# :var WORKSPACE: Location where build is started, defaults to ``.``
+# :type WORKSPACE: path
+#
+#
+# .. requirements::
+#
+# * ``tox`` in ``/usr/bin/tox`
+#
+#
+# .. seealso:: https://bugs.launchpad.net/fuel/+bug/1496987
+# .. warnings:: never use on production for test purposes
+
+set -ex
+
+tox --help || apt install -y python-tox
+tox -e views
+
+source ".tox/ci-views/bin/activate"
+
+CONFIG_PATH="${WORKSPACE}/../tmp/${JOB_NAME}"
+
+umask 0077
+mkdir -p "${CONFIG_PATH}"
+cat > "${CONFIG_PATH}/jenkins_jobs.ini" << EOF
+[jenkins]
+user=${JJB_USER}
+password=${JJB_PASS}
+url=${JENKINS_URL}
+EOF
+
+cd "views/${CI_NAME}"
+
+if [ -n "$VIEWS_LIST" ] ; then
+ VIEWS_LIST=(${VIEWS_LIST})
+else
+ VIEWS_LIST=(*)
+fi
+
+jenkins-view-builder update --conf "${CONFIG_PATH}/jenkins_jobs.ini" "${VIEWS_LIST[@]}"
--- /dev/null
+[jenkins]
+user=my_username
+password=my_secret_password
+url=https://my.jenkins.com/
+query_plugins_info=False
+
+[job_builder]
+ignore_cache=True
+keep_descriptions=False
+recursive=True
+include_path=.:scripts
+
+[__future__]
+param_order_from_yaml=true
--- /dev/null
+jenkins-job-builder
+cmd2
--- /dev/null
+jenkins-view-builder
+cmd2
+cliff
--- /dev/null
+[tox]
+minversion = 1.6
+skipsdist = True
+envlist = jobs,views
+
+[testenv]
+basepython = python2
+usedevelop = False
+
+[testenv:jobs]
+deps = -r{toxinidir}/conf/requirements-jobs.txt
+commands =
+ jenkins-jobs --conf conf/jenkins_job.ini.example test -x common/data common:mos:mcp -o {toxinidir}/output/jobs --config-xml
+
+[testenv:views]
+deps = -r{toxinidir}/conf/requirements-views.txt
+commands =
+ /bin/bash -c 'jenkins-view-builder test views/* -o {toxinidir}/output/views/patching-ci'