blob: 2fcfd8a3868b8274968639bc2af8038ff018cb8e [file] [log] [blame]
- job:
name: arthur-tf-a-lts-automation
node: build-amd64-private
project-type: freestyle
disabled: false
defaults: global
description: |
Trusted Firmware A LTS automation
properties:
- build-discarder:
days-to-keep: 15
parameters:
- string:
name: import_cc
- string:
name: EMAIL_RECIPIENT
default: arthur.she@linaro.org
description: |
Email notification recipient
wrappers:
- timestamps
- timeout:
timeout: 120
fail: true
- credentials-binding:
- ssh-user-private-key:
credential-id: TFA_CI_BOT_USER_SSH_KEY
key-file-variable: CI_BOT_KEY
username-variable: CI_BOT_USERNAME
passphrase-variable: ''
triggers:
- gerrit:
silent: true
server-name: 'review.trustedfirmware.org'
projects:
- branches:
- branch-compare-type: REG_EXP
branch-pattern: 'arthur-lts-v.*'
project-compare-type: PLAIN
project-pattern: 'next/TF-A/trusted-firmware-a'
trigger-on:
- ref-updated-event
builders:
- shell: |
echo "***************************************"
env | grep GERRIT
echo "***************************************"
- shell: |
#!/bin/bash
set -ex
SSH_PARAMS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAcceptedKeyTypes=+ssh-rsa"
export GIT_SSH_COMMAND="ssh -p 29418 -i $CI_BOT_KEY ${SSH_PARAMS}"
gerrit_host="ssh://${CI_BOT_USERNAME}@${GERRIT_HOST}:29418"
new_branch=${GERRIT_REFNAME}
forked_tag=${new_branch##*-}
_workdir=$(mktemp -d)
trap '[ -d "${_workdir}" ] && rm -rf "${_workdir}"' EXIT
git -C "${_workdir}" init > /dev/null 2>&1
# Check if the job is triggered by a new LTS branch creation
new_lts_branch=1
git -C "${_workdir}" fetch ${gerrit_host}/${GERRIT_PROJECT} ${new_branch} || new_lts_branch=-1
if [ ${new_lts_branch} -eq -1 ]; then
echo "No new LTS branch created! exit job"
exit 0
fi
# Create new LTS branch to related repositories
repos="next/TF-A/tf-a-tests next/ci/tf-a-ci-scripts"
for r in ${repos};
do
echo "Create branch \"${new_branch}\" from tag \"${forked_tag}\" in the \"${r}\" project"
git -C "${_workdir}" fetch ${gerrit_host}/${r} ${forked_tag}
git -C "${_workdir}" push ${gerrit_host}/${r} FETCH_HEAD^{commit}:refs/heads/${new_branch}
done
# Create new download space
echo "Create new download space for \"${new_branch}\""
#aws s3 sync --dryrun s3://trustedfirmware-prod-storage/tf-a s3://trustedfirmware-prod-storage/tf-a-${new_branch}
#
cat << EOF >email.txt
Hello,
The new LTS branch "${new_branch}" has been created in the following repositoris
${repos}
And the new download space is ready on https://downloads.trustedfirmware.org/tf-a-${new_branch}
EOF
cat email.txt
publishers:
- conditional-publisher:
- condition-kind: file-exists
on-evaluation-failure: dont-run
condition-filename: email.txt
condition-basedir: workspace
action:
- email-ext:
always: true
recipients: ${EMAIL_RECIPIENT}
subject: "Build Success: ${JOB_NAME} #${BUILD_NUMBER}"
body: '${FILE,path="email.txt"}'