From: Eric Ball Date: Tue, 2 Apr 2019 01:12:39 +0000 (+0000) Subject: Merge "[iec] Add deploy jobs" X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ci-management.git;a=commitdiff_plain;h=952b8e31a099b3c9d7a8c40b126c26a11220e2ad;hp=ae2d70f55587ca3677df1e155cf4770af0e92156 Merge "[iec] Add deploy jobs" --- diff --git a/jenkins-config/clouds/openstack/cattle/centos7-builder-8c-8g.cfg b/jenkins-config/clouds/openstack/cattle/centos7-builder-8c-8g.cfg new file mode 100644 index 0000000..04b10e5 --- /dev/null +++ b/jenkins-config/clouds/openstack/cattle/centos7-builder-8c-8g.cfg @@ -0,0 +1,2 @@ +IMAGE_NAME=ZZCI - CentOS 7 - builder - x86_64 - 20181010-215635.956 +HARDWARE_ID=v2-highcpu-8 diff --git a/jjb/akraino-templates/akraino-jjb-templates.yaml b/jjb/akraino-templates/akraino-jjb-templates.yaml index 33035f1..58320ce 100644 --- a/jjb/akraino-templates/akraino-jjb-templates.yaml +++ b/jjb/akraino-templates/akraino-jjb-templates.yaml @@ -282,7 +282,6 @@ - lf-infra-parameters: project: '{project}' stream: '{stream}' - refspec: '{refspec}' branch: '{branch}' lftools-version: '{lftools-version}' @@ -300,11 +299,11 @@ - lf-infra-gerrit-scm: jenkins-ssh-credential: '{jenkins-ssh-credential}' git-url: '{git-url}/{project}.git' - refspec: '{refspec}' - branch: '{branch}' + refspec: '$GERRIT_REFSPEC' + branch: '$GERRIT_BRANCH' submodule-recursive: '{submodule-recursive}' submodule-timeout: '{submodule-timeout}' - choosing-strategy: default + choosing-strategy: 'gerrit' triggers: - gerrit: @@ -316,8 +315,6 @@ exclude-no-code-change: 'false' - change-merged-event - draft-published-event - - comment-added-contains-event: - comment-contains-value: remerge$ - comment-added-contains-event: comment-contains-value: 'recheck' - comment-added-contains-event: @@ -337,11 +334,9 @@ pattern: 'docs/**' readable-message: true - - builders: - shell: !include-raw-escape: - - ../shell/eliot-verify.sh + - ../shell/verify.sh publishers: - lf-infra-publish diff --git a/jjb/camunda_workflow/camunda_workflow-docker.yaml b/jjb/camunda_workflow/camunda_workflow-docker.yaml index 334e2cb..5e1d5e6 100644 --- a/jjb/camunda_workflow/camunda_workflow-docker.yaml +++ b/jjb/camunda_workflow/camunda_workflow-docker.yaml @@ -24,7 +24,7 @@ java-version: openjdk8 mvn-version: mvn35 mvn-opts: '' - mvn-params: '-f akraino/pom.xml' + mvn-params: '-f akraino' mvn-settings: camunda_workflow-settings build-timeout: 60 submodule-recursive: true diff --git a/jjb/camunda_workflow/camunda_workflow.yaml b/jjb/camunda_workflow/camunda_workflow.yaml index 110fcb7..1bdd573 100644 --- a/jjb/camunda_workflow/camunda_workflow.yaml +++ b/jjb/camunda_workflow/camunda_workflow.yaml @@ -19,7 +19,7 @@ project: camunda_workflow project-name: camunda_workflow mvn-settings: camunda_workflow-settings - mvn-params: '-f akraino/pom.xml' + mvn-params: '-f akraino' nexus-iq-namespace: 'akraino-' build-node: centos7-builder-2c-1g stream: master diff --git a/jjb/eliot/eliot.yaml b/jjb/eliot/eliot.yaml index c762473..632fe8b 100644 --- a/jjb/eliot/eliot.yaml +++ b/jjb/eliot/eliot.yaml @@ -3,9 +3,9 @@ name: eliot-project project-name: eliot project: eliot - stream: master - refspec: '$GERRIT_REFSPEC' - branch: '$GERRIT_BRANCH' + stream: + - master: + branch: master build-node: centos7-builder-2c-1g jobs: - akraino-project-stream-verify diff --git a/jjb/portal_user_interface/portal_user_interface-docker.yaml b/jjb/portal_user_interface/portal_user_interface-docker.yaml index f11996b..38536a6 100644 --- a/jjb/portal_user_interface/portal_user_interface-docker.yaml +++ b/jjb/portal_user_interface/portal_user_interface-docker.yaml @@ -24,7 +24,7 @@ java-version: openjdk8 mvn-version: mvn35 mvn-opts: '' - mvn-params: '-f AECPortalMgmt/pom.xml' + mvn-params: '-f AECPortalMgmt' mvn-settings: portal_user_interface-settings build-timeout: 60 submodule-recursive: true diff --git a/jjb/portal_user_interface/portal_user_interface.yaml b/jjb/portal_user_interface/portal_user_interface.yaml index 40142c1..ce31a82 100644 --- a/jjb/portal_user_interface/portal_user_interface.yaml +++ b/jjb/portal_user_interface/portal_user_interface.yaml @@ -19,7 +19,7 @@ project: portal_user_interface project-name: portal_user_interface mvn-settings: portal_user_interface-settings - mvn-params: '-f AECPortalMgmt/pom.xml' + mvn-params: '-f AECPortalMgmt' nexus-iq-namespace: 'akraino-' build-node: centos7-builder-2c-1g stream: master diff --git a/jjb/shell/eliot-verify.sh b/jjb/shell/verify.sh similarity index 95% rename from jjb/shell/eliot-verify.sh rename to jjb/shell/verify.sh index 1c80a16..eff7d25 100644 --- a/jjb/shell/eliot-verify.sh +++ b/jjb/shell/verify.sh @@ -17,6 +17,6 @@ set -o errexit set -o pipefail -echo "Running eliot verification..." +echo "Running verify.sh..." /bin/bash $WORKSPACE/verify.sh diff --git a/utils/jenkins-jnlp-connect.sh b/utils/jenkins-jnlp-connect.sh new file mode 100755 index 0000000..979388b --- /dev/null +++ b/utils/jenkins-jnlp-connect.sh @@ -0,0 +1,233 @@ +#!/bin/bash +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2016 Linux Foundation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +#Monit setup script for akraino jnlp agent connections + +test_firewall() { +jenkins_hostname="${jenkins_hostname:-jenkins.akraino.org}" + + + echo "testing that the firewall is open for us at $jenkins_hostname" + test=$(echo "blah"| nc -w 4 "$jenkins_hostname" 57387 > /dev/null 2>&1; echo $?) + if [[ $test == 0 ]]; then + echo "Firewall is open for us at $jenkins_hostname" + exit 0 + else + cat << EOF +LF firewall not open, please send a report to helpdesk with your gpg key attached, or better yet upload it to the key servers. (I should be able to find it with gpg --search-keys your@company.email.com +akrino-helpdesk@rt.linuxfoundation.org +Jenkins Home: $jenkinshome +Jenkins User: $jenkinsuser +Slave Name: $agent_name +IP Address: $(curl -s http://icanhazip.com) +EOF + exit 1 + fi +} + +main () { + #tests + if [[ -z $jenkinsuser || -z $jenkinshome ]]; then + echo "jenkinsuser or home not defined, please edit this file to define it" + exit 1 + fi + + if [[ $(pwd) != "$jenkinshome" ]]; then + echo "This script needs to be run from the jenkins users home dir" + echo "You are at $(pwd); jenkins home is set at $jenkinshome" + exit 1 + fi + + if [[ -z $agent_name || -z $agent_secret ]]; then + echo "agent name or secret not defined, please edit this file to define it" + exit 1 + fi + + if [[ $(whoami) != "root" && $(whoami) != "$jenkinsuser" ]]; then + echo "This script must be run as user root or jenkins user" + exit 1 + fi + + if [[ $(whoami) != "root" ]]; then + if sudo -l | grep "requiretty" | grep -v "\!requiretty"; then + echo "please comment out Defaults requiretty from /etc/sudoers" + exit 1 + fi + fi + + #make pid dir + if [[ ${SANDBOX} == true ]]; then + monit_service="sandbox" + else + monit_service="jenkins" + fi + + pidfile="/var/run/$monit_service/${monit_service}_jnlp_pid" + if ! [ -d /var/run/"${monit_service}"/ ]; then + sudo mkdir /var/run/"$monit_service"/ + sudo chown "$jenkinsuser":"$jenkinsuser" /var/run/"$monit_service"/ + fi + + if [[ $skip_monit != true ]]; then + #check for monit + if [ -n "$(command which monit)" ]; then + echo "monit installed" + else + if [ -n "$(command -v yum)" ]; then + echo "please install monit; eg: yum -y install monit" + exit 1 + elif [ -n "$(command -v apt-get)" ]; then + echo "please install monit; eg: apt-get install -y monit" + exit 1 + else + echo "system not supported plese contact help desk" + exit 1 + fi + fi + + if [ -d /etc/monit/conf.d ]; then + monitconfdir="/etc/monit/conf.d/" + monitconfig="/etc/monit/monitrc" + #add start delay + sed -i '/^#.* delay /s/^#//' "$monitconfig" + elif [ -d /etc/monit.d ]; then + monitconfdir="/etc/monit.d" + monitconfig="/etc/monitrc" + #add start delay + sed -i '/^#.* delay /s/^#//' "$monitconfig" + else + echo "Could not determine the location of the monit configuration file." + echo "Make sure monit is installed." + exit 1 + fi + + chown=$(type -p chown) + mkdir=$(type -p mkdir) + + makemonit () { + echo "Writing the following as monit config:" + + cat << EOF | tee $monitconfdir/$monit_service +check directory ${monit_service}_piddir path /var/run/$monit_service +if does not exist then exec "$mkdir -p /var/run/$monit_service" +if failed uid $jenkinsuser then exec "$chown $jenkinsuser /var/run/$monit_service" +if failed gid $jenkinsuser then exec "$chown :$jenkinsuser /var/run/$monit_service" +check process $monit_service with pidfile $pidfile +start program = "/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $jenkinshome; export started_monit=true; $0 $@' with timeout 60 seconds" +stop program = "/bin/bash -c '/bin/kill \$(/bin/cat $pidfile)'" +depends on ${monit_service}_piddir +EOF + } + + if [[ -f "$monitconfdir/$monit_service" ]]; then + #test for diff + if [[ -n "$(diff $monitconfdir/$monit_service <(echo "\ +check directory ${monit_service}_piddir path /var/run/$monit_service +if does not exist then exec \"$mkdir -p /var/run/$monit_service\" +if failed uid $jenkinsuser then exec \"$chown $jenkinsuser /var/run/$monit_service\" +if failed gid $jenkinsuser then exec \"$chown :$jenkinsuser /var/run/$monit_service\" +check process jenkins with pidfile $pidfile +start program = \"/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $jenkinshome; export started_monit=true; $0 $@' with timeout 60 seconds\" +stop program = \"/bin/bash -c '/bin/kill \$(/bin/cat $pidfile)'\" +depends on ${monit_service}_piddir\ +") )" ]]; then + echo "Updating monit config..." + makemonit "$@" + fi + else + makemonit "$@" + fi + fi + + if [[ $started_monit == "true" ]]; then + wget --timestamping https://"$jenkins_hostname"/jnlpJars/agent.jar && true + chown "$jenkinsuser":"$jenkinsuser" agent.jar + + if [[ -f $pidfile ]]; then + echo "pid file found" + if ! kill -0 "$(/bin/cat "$pidfile")"; then + echo "no java process running cleaning up pid file" + rm -f "$pidfile"; + else + echo "java connection process found and running already running quitting." + exit 1 + fi + fi + + if [[ $run_in_foreground == true ]]; then + $connectionstring + else + exec ${connectionstring} & + echo $! > $pidfile + fi + else + echo "you are ready to start monit" + echo "eg: service monit start" + echo "example debug mode if you are having problems: /usr/bin/monit -Ivv -c /etc/monit.conf " + exit 0 + fi +} + +usage() { + cat << EOF +**this file must be copied to the jenkins home directory to work** +jenkins-jnlp-connect.sh configures monit to keep agent connection up +Checks for new versions of agent.jar +run as root to create pid directory and create monit config. +can be run as root additional times if you change variables and need to update monit config. +after running as root you should see "you are ready to start monit" +usage: $0 [OPTIONS] + -h show this message + -j set jenkins home + -u set jenkins user + -n set agent name + -s set secret key + -l set host, default is jenkins.akraino.org + -b set flag that this connection is for sandbox; default is jenkins.akraino.org/sandbox + -t test the connection string by connecting without monit + -f test firewall +Example: $0 -j /home/jenkins -u jenkins -n lab1 -s 727fdefoofoofoofoofoofoofof800 +note: a trailing slash on -j /home/jenkins will break the script +EOF + + exit 1 +} + +if [[ -z "$@" ]]; then + usage +fi + +while getopts "j:u:n:s:l:bhtf" OPTION +do + case $OPTION in + j ) jenkinshome="$OPTARG" ;; + u ) jenkinsuser="$OPTARG" ;; + n ) agent_name="$OPTARG" ;; + s ) agent_secret="$OPTARG";; + l ) jenkins_hostname="$OPTARG" ;; + b ) SANDBOX=true ;; + h ) usage ;; + t ) started_monit=true + skip_monit=true + run_in_foreground=true ;; + f ) test_firewall ;; + \? ) echo "Unknown option: -$OPTARG" >&2; exit 1;; + esac +done + +if [[ ${SANDBOX} == true ]]; then + jenkins_hostname="${jenkins_hostname:-jenkins.akraino.org/sandbox}" +else + jenkins_hostname="${jenkins_hostname:-jenkins.akraino.org}" +fi +echo "hostname is ${jenkins_hostname}" + +connectionstring="java -jar agent.jar -jnlpUrl https://$jenkins_hostname/computer/$agent_name/slave-agent.jnlp -secret $agent_secret -noCertificateCheck " +main "$@"