<!-- Managed by Jenkins Job Builder -->
false
false
false
false
build-vm
false
https://github.com/example-org/releng/ciman
PROJECT
Parameter to identify a Gerrit project. This is typically the
project repo path as exists in Gerrit.
For example: ofextensions/circuitsw
releng/ciman
STREAM
Stream is often set to the same name as 'branch' but can
sometimes be used as a name representing a project's release code
name.
master
GERRIT_PROJECT
Parameter to identify Gerrit project. This is typically the
project repo path as exists in Gerrit.
For example: ofextensions/circuitsw
Note that Gerrit will override this parameter automatically if a
job is triggered by Gerrit.
releng/ciman
GERRIT_BRANCH
Parameter to identify a Gerrit branch.
Note that Gerrit will override this parameter automatically if a
job is triggered by Gerrit.
master
GERRIT_REFSPEC
Parameter to identify a refspec when pulling from Gerrit.
Note that Gerrit will override this parameter automatically if a
job is triggered by Gerrit.
PACKER_VERSION
Packer version to download and install.
1.0.2
2
origin
git@github.com:example-org/releng/ciman
test-credential
**
false
false
true
false
false
Default
true
false
false
false
true
false
10
00 10 1 * *
false
tykeal
false
jpwku
tykeal
zxiiro
example-org
^remerge$
true
true
false
false
Packer centos-$mininet Merge
ci-packer-cloud-env
CLOUDENV
PACKER_VERSION=1.0.2
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 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
##############################################################################
echo "---> packer-install.sh"
# The script checks for the packer binaries and installs the binary
# if its not available
# $PACKER_VERSION : Define a packer version passed as job paramter
PACKER_VERSION="${PACKER_VERSION:-1.0.2}"
# Ensure we fail the job if any steps fail.
set -eu -o pipefail
# Default packer binary made available on the build image
packer_bin="/usr/local/bin/packer.io"
if hash "$packer_bin" 2>/dev/null; then
echo "packer.io command is available."
else
echo "packer.io command not is available. Installing packer ..."
# Installs Hashicorp's Packer binary, required for verify & merge packer jobs
pushd packer
wget "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
mkdir -p "${WORKSPACE}/bin"
unzip "packer_${PACKER_VERSION}_linux_amd64.zip" -d ${WORKSPACE}/bin/
# rename packer to avoid conflict with binary in cracklib
mv ${WORKSPACE}/bin/packer "${WORKSPACE}/bin/packer.io"
popd
fi
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 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
##############################################################################
echo "---> packer-validate.sh"
# The script validates an packers files.
# $CLOUDENV : Provides the cloud credential file.
# Ensure we fail the job if any steps fail.
set -eu -o pipefail
PACKER_LOGS_DIR="$WORKSPACE/archives/packer"
mkdir -p "$PACKER_LOGS_DIR"
export PATH="${WORKSPACE}/bin:$PATH"
cd packer
varfiles=(../packer/vars/*.json)
templates=(../packer/templates/*.json)
for varfile in "${varfiles[@]}"; do
for template in "${templates[@]}"; do
export PACKER_LOG="yes" && \
export PACKER_LOG_PATH="$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log" && \
packer.io validate -var-file="$CLOUDENV" \
-var-file="$varfile" "$template"
if [ $? -ne 0 ]; then
break
fi
done
done
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 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
##############################################################################
echo "---> packer-clear-credentials.sh"
set +e # DO NOT cause build failure if any of the rm calls fail.
rm "$CLOUDENV"
exit 0
ci-packer-cloud-env
CLOUDENV
PACKER_PLATFORM=centos
PACKER_TEMPLATE=mininet
PACKER_VERSION=1.0.2
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 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
##############################################################################
echo "---> packer-install.sh"
# The script checks for the packer binaries and installs the binary
# if its not available
# $PACKER_VERSION : Define a packer version passed as job paramter
PACKER_VERSION="${PACKER_VERSION:-1.0.2}"
# Ensure we fail the job if any steps fail.
set -eu -o pipefail
# Default packer binary made available on the build image
packer_bin="/usr/local/bin/packer.io"
if hash "$packer_bin" 2>/dev/null; then
echo "packer.io command is available."
else
echo "packer.io command not is available. Installing packer ..."
# Installs Hashicorp's Packer binary, required for verify & merge packer jobs
pushd packer
wget "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip"
mkdir -p "${WORKSPACE}/bin"
unzip "packer_${PACKER_VERSION}_linux_amd64.zip" -d ${WORKSPACE}/bin/
# rename packer to avoid conflict with binary in cracklib
mv ${WORKSPACE}/bin/packer "${WORKSPACE}/bin/packer.io"
popd
fi
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 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
##############################################################################
echo "---> packer-build.sh"
# The script builds an image using packer
# $CLOUDENV : Provides the cloud credential file.
# $PACKER_PLATFORM : Provides the packer platform.
# $PACKER_TEMPLATE : Provides the packer temnplate.
# Ensure we fail the job if any steps fail.
set -eu -o pipefail
PACKER_LOGS_DIR="$WORKSPACE/archives/packer"
PACKER_BUILD_LOG="$PACKER_LOGS_DIR/packer-build.log"
mkdir -p "$PACKER_LOGS_DIR"
export PATH="${WORKSPACE}/bin:$PATH"
cd packer
export PACKER_LOG="yes" && \
export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \
packer.io build -color=false \
-var-file="$CLOUDENV" \
-var-file="../packer/vars/$PACKER_PLATFORM.json" \
"../packer/templates/$PACKER_TEMPLATE.json"
# Retrive the list of cloud providers
clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json"))
# Split public/private clouds logs
for cloud in "${clouds[@]}"; do
grep -e "$cloud" "$PACKER_BUILD_LOG" > "$PACKER_LOGS_DIR/packer-build_$cloud.log" 2>&1
done
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 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
##############################################################################
echo "---> packer-clear-credentials.sh"
set +e # DO NOT cause build failure if any of the rm calls fail.
rm "$CLOUDENV"
exit 0
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 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
##############################################################################
echo "---> sysstat.sh"
set +e # DON'T fail build if script fails.
OS=$(facter operatingsystem)
case "$OS" in
Ubuntu)
SYSSTAT_PATH="/var/log/sysstat"
# Dont run the script when systat is not enabled by default
if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
exit 0
fi
;;
CentOS|RedHat)
SYSSTAT_PATH="/var/log/sa"
;;
*)
# nothing to do
exit 0
;;
esac
SAR_DIR="$WORKSPACE/archives/sar-reports"
mkdir -p "$SAR_DIR"
cp "$SYSSTAT_PATH/"* "$_"
# convert sar data to ascii format
while IFS="" read -r s
do
[ -f "$s" ] && LC_TIME=POSIX sar -A -f "$s" > "$SAR_DIR/sar${s//[!0-9]/}"
done < <(find "$SYSSTAT_PATH" -name "sa[0-9]*" || true)
# DON'T fail build if script fails.
exit 0
jenkins-log-archives-settings
SETTINGS_FILE
SERVER_ID=logs
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 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
##############################################################################
echo "---> create-netrc.sh"
# Ensure we fail the job if any steps fail.
set -eu -o pipefail
NEXUS_URL="${NEXUS_URL:-$NEXUSPROXY}"
CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
-t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
-v x:username -o ":" -v x:password \
"$SETTINGS_FILE")
machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
user=$(echo "$CREDENTIAL" | cut -f1 -d:)
pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
echo "machine $machine login $user password $pass" > ~/.netrc
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 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
##############################################################################
echo "---> lftools-install.sh"
# Ensure we fail the job if any steps fail.
# DO NOT set -u as virtualenv's activate script has unbound variables
set -e -o pipefail
virtualenv --quiet "/tmp/v/lftools"
# shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
source "/tmp/v/lftools/bin/activate"
pip install --quiet --upgrade pip
pip install --quiet --upgrade "lftools<1.0.0"
# pipdeptree prints out a lot of information because lftools pulls in many
# dependencies. Let's only print it if we want to debug.
# echo "----> Pip Dependency Tree"
# pip install --quiet --upgrade pipdeptree
# pipdeptree
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 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
##############################################################################
echo "---> logs-deploy.sh"
# Ensure we fail the job if any steps fail.
set -eu -o pipefail
set -x # Trace commands for this script to make debugging easier.
ARCHIVE_ARTIFACTS="${ARCHIVE_ARTIFACTS:-}"
LOGS_SERVER="${LOGS_SERVER:-None}"
if [ "${LOGS_SERVER}" == 'None' ]
then
set +x # Disable trace since we no longer need it
echo "WARNING: Logging server not set"
else
NEXUS_URL="${NEXUS_URL:-$NEXUSPROXY}"
NEXUS_PATH="${SILO}/${JENKINS_HOSTNAME}/${JOB_NAME}/${BUILD_NUMBER}"
BUILD_URL="${BUILD_URL}"
lftools deploy archives -p "$ARCHIVE_ARTIFACTS" "$NEXUS_URL" "$NEXUS_PATH" "$WORKSPACE"
lftools deploy logs "$NEXUS_URL" "$NEXUS_PATH" "$BUILD_URL"
set +x # Disable trace since we no longer need it.
echo "Build logs: <a href=\"$LOGS_SERVER/$NEXUS_PATH\">$LOGS_SERVER/$NEXUS_PATH</a>"
fi
#!/bin/bash
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 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
##############################################################################
# Clear log credential files
rm "$SETTINGS_FILE"
rm ~/.netrc
^Build logs: .*
false
false
false
**/*.jenkins-trigger
EXCLUDE
false
false
true
true
true
true
true
true
45
BUILD_TIMEOUT
true
false
0
3
absolute
test-credential