blob: 14f45e4ac255fe067a78f9c6000117b37ae6f534 [file] [log] [blame]
Chris Kayc1aa7ba2025-06-12 16:56:38 +01001- job:
2 name: tf-a-lts-automation
3 node: build-amd64-private
4 project-type: freestyle
5 disabled: false
6 defaults: global
7 description: |
8 Trusted Firmware A LTS automation, this job triggered by a new LTS branch created in the trusted-firmware-a repository.
9 It helps to create corrosponding branch in the tf-a-test, hafnium, and tf-a-ci-scripts repositories, as well as set up a new download
10 space for the new LTS branch.
11 properties:
Chris Kaybb674402025-06-24 15:20:02 +010012 - build-discarder:
13 days-to-keep: 15
Chris Kayc1aa7ba2025-06-12 16:56:38 +010014 parameters:
Chris Kaybb674402025-06-24 15:20:02 +010015 - string:
16 name: EMAIL_RECIPIENT
17 default: |
18 bipin.ravi@arm.com, vwadekar@nvidia.com, yann.gautier@st.com, jidong@google.com, govindraj.raja@arm.com, arthur.she@linaro.org
19 description: |
20 The notification recipients
Chris Kayc1aa7ba2025-06-12 16:56:38 +010021 wrappers:
Chris Kaybb674402025-06-24 15:20:02 +010022 - timestamps
23 - timeout:
24 timeout: 120
25 fail: true
26 - credentials-binding:
27 - ssh-user-private-key:
28 credential-id: TFA_CI_BOT_USER_SSH_KEY
29 key-file-variable: CI_BOT_KEY
30 username-variable: CI_BOT_USERNAME
31 passphrase-variable: ""
Chris Kayc1aa7ba2025-06-12 16:56:38 +010032 builders:
Chris Kaybb674402025-06-24 15:20:02 +010033 - shell: |
34 echo "***************************************"
35 env | grep GERRIT
36 echo "***************************************"
37 - shell: |
38 #!/bin/bash
39 set -ex
Chris Kayc1aa7ba2025-06-12 16:56:38 +010040
Chris Kaybb674402025-06-24 15:20:02 +010041 SSH_PARAMS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAcceptedKeyTypes=+ssh-rsa"
42 export GIT_SSH_COMMAND="ssh -p 29418 -i $CI_BOT_KEY ${SSH_PARAMS}"
43 gerrit_host="ssh://${CI_BOT_USERNAME}@${GERRIT_HOST}:29418"
44 new_branch=${GERRIT_REFNAME}
45 forked_tag=${new_branch##*-}
Chris Kayc1aa7ba2025-06-12 16:56:38 +010046
Chris Kaybb674402025-06-24 15:20:02 +010047 _workdir=$(mktemp -d)
48 rm -f email.txt || true
49 trap '[ -d "${_workdir}" ] && rm -rf "${_workdir}"' EXIT
50 git -C "${_workdir}" init > /dev/null 2>&1
Chris Kayc1aa7ba2025-06-12 16:56:38 +010051
Chris Kaybb674402025-06-24 15:20:02 +010052 # Check if the job is triggered by a new LTS branch creation
53 new_lts_branch=-1
54 # Verify if the branch already exists in the Hafnium project.
55 git -C "${_workdir}" ls-remote --exit-code ${gerrit_host}/hafnium/hafnium ${new_branch} || new_lts_branch=1
56 # Check if the job is not triggered by delete branch
57 git -C "${_workdir}" ls-remote --exit-code ${gerrit_host}/${GERRIT_PROJECT} ${new_branch} || new_lts_branch=-1
58 if [ ${new_lts_branch} -eq -1 ]; then
59 echo "No new LTS branch created! exit job"
60 exit 0
61 fi
Chris Kayc1aa7ba2025-06-12 16:56:38 +010062
Chris Kaybb674402025-06-24 15:20:02 +010063 # Create new LTS branch to related repositories
64 repos="hafnium/hafnium TF-A/tf-a-tests ci/tf-a-ci-scripts ci/tf-a-job-configs"
65 for r in ${repos};
66 do
67 echo "Create branch \"${new_branch}\" from tag \"${forked_tag}\" in the \"${r}\" project"
68 git -C "${_workdir}" fetch ${gerrit_host}/${r} ${forked_tag}
69 git -C "${_workdir}" push ${gerrit_host}/${r} FETCH_HEAD^{commit}:refs/heads/${new_branch}
70 done
Chris Kayc1aa7ba2025-06-12 16:56:38 +010071
Chris Kaybb674402025-06-24 15:20:02 +010072 # Create new download space
73 echo "Create new download space for \"${new_branch}\""
74 aws s3 sync s3://trustedfirmware-prod-storage/tf-a s3://openci-trustedfirmware-storage-prod/tf-a-${new_branch}
Chris Kayc1aa7ba2025-06-12 16:56:38 +010075
Chris Kaybb674402025-06-24 15:20:02 +010076 echo "CI Environment Setup for ${new_branch} branch Completed" > subject.txt
77 cat << EOF >email.txt
78 Hello,
79 The new LTS branch "${new_branch}" has been created in the following repositoris
80 ${repos}
Chris Kayc1aa7ba2025-06-12 16:56:38 +010081
Chris Kaybb674402025-06-24 15:20:02 +010082 And the new download space is ready on ${DOWNLOAD_SERVER_URL}/tf-a-${new_branch}
Chris Kayc1aa7ba2025-06-12 16:56:38 +010083
Chris Kaybb674402025-06-24 15:20:02 +010084 Please check the job log for the details
85 ${BUILD_URL}console
Chris Kayc1aa7ba2025-06-12 16:56:38 +010086
Chris Kaybb674402025-06-24 15:20:02 +010087 EOF
Chris Kayc1aa7ba2025-06-12 16:56:38 +010088
Chris Kaybb674402025-06-24 15:20:02 +010089 echo "--------- email body ----------"
90 cat email.txt
Chris Kayc1aa7ba2025-06-12 16:56:38 +010091 publishers:
92 - conditional-publisher:
93 - condition-kind: file-exists
94 on-evaluation-failure: dont-run
95 condition-filename: email.txt
96 condition-basedir: workspace
97 action:
98 - email-ext:
99 always: true
100 recipients: ${EMAIL_RECIPIENT}
Chris Kaybb674402025-06-24 15:20:02 +0100101 subject: ${FILE,path="subject.txt"}
102 body: ${FILE,path="email.txt"}