Chris Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 1 | - 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 Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 12 | - build-discarder: |
| 13 | days-to-keep: 15 |
Chris Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 14 | parameters: |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 15 | - 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 Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 21 | wrappers: |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 22 | - 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 Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 32 | builders: |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 33 | - shell: | |
| 34 | echo "***************************************" |
| 35 | env | grep GERRIT |
| 36 | echo "***************************************" |
| 37 | - shell: | |
| 38 | #!/bin/bash |
| 39 | set -ex |
Chris Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 40 | |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 41 | 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 Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 46 | |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 47 | _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 Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 51 | |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 52 | # 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 Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 62 | |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 63 | # 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 Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 71 | |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 72 | # 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 Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 75 | |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 76 | 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 Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 81 | |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 82 | And the new download space is ready on ${DOWNLOAD_SERVER_URL}/tf-a-${new_branch} |
Chris Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 83 | |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 84 | Please check the job log for the details |
| 85 | ${BUILD_URL}console |
Chris Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 86 | |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 87 | EOF |
Chris Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 88 | |
Chris Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 89 | echo "--------- email body ----------" |
| 90 | cat email.txt |
Chris Kay | c1aa7ba | 2025-06-12 16:56:38 +0100 | [diff] [blame] | 91 | 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 Kay | bb67440 | 2025-06-24 15:20:02 +0100 | [diff] [blame] | 101 | subject: ${FILE,path="subject.txt"} |
| 102 | body: ${FILE,path="email.txt"} |