Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [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 | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 12 | - build-discarder: |
| 13 | days-to-keep: 15 |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 14 | parameters: |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +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 |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 21 | wrappers: |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +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: "" |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 32 | triggers: |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 33 | - gerrit: |
| 34 | silent: true |
| 35 | server-name: review.trustedfirmware.org |
| 36 | projects: |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 37 | - branches: |
| 38 | - branch-compare-type: REG_EXP |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 39 | branch-pattern: lts-v.* |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 40 | project-compare-type: PLAIN |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 41 | project-pattern: TF-A/trusted-firmware-a |
| 42 | trigger-on: |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 43 | - ref-updated-event |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 44 | builders: |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 45 | - shell: | |
| 46 | echo "***************************************" |
| 47 | env | grep GERRIT |
| 48 | echo "***************************************" |
| 49 | - shell: | |
| 50 | #!/bin/bash |
| 51 | set -ex |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 52 | |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 53 | SSH_PARAMS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAcceptedKeyTypes=+ssh-rsa" |
| 54 | export GIT_SSH_COMMAND="ssh -p 29418 -i $CI_BOT_KEY ${SSH_PARAMS}" |
| 55 | gerrit_host="ssh://${CI_BOT_USERNAME}@${GERRIT_HOST}:29418" |
| 56 | new_branch=${GERRIT_REFNAME} |
| 57 | forked_tag=${new_branch##*-} |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 58 | |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 59 | _workdir=$(mktemp -d) |
| 60 | rm -f email.txt || true |
| 61 | trap '[ -d "${_workdir}" ] && rm -rf "${_workdir}"' EXIT |
| 62 | git -C "${_workdir}" init > /dev/null 2>&1 |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 63 | |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 64 | # Check if the job is triggered by a new LTS branch creation |
| 65 | new_lts_branch=-1 |
| 66 | # Verify if the branch already exists in the Hafnium project. |
| 67 | git -C "${_workdir}" ls-remote --exit-code ${gerrit_host}/hafnium/hafnium ${new_branch} || new_lts_branch=1 |
| 68 | # Check if the job is not triggered by delete branch |
| 69 | git -C "${_workdir}" ls-remote --exit-code ${gerrit_host}/${GERRIT_PROJECT} ${new_branch} || new_lts_branch=-1 |
| 70 | if [ ${new_lts_branch} -eq -1 ]; then |
| 71 | echo "No new LTS branch created! exit job" |
| 72 | exit 0 |
| 73 | fi |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 74 | |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 75 | # Create new LTS branch to related repositories |
| 76 | repos="hafnium/hafnium TF-A/tf-a-tests ci/tf-a-ci-scripts ci/tf-a-job-configs" |
| 77 | for r in ${repos}; |
| 78 | do |
| 79 | echo "Create branch \"${new_branch}\" from tag \"${forked_tag}\" in the \"${r}\" project" |
| 80 | git -C "${_workdir}" fetch ${gerrit_host}/${r} ${forked_tag} |
| 81 | git -C "${_workdir}" push ${gerrit_host}/${r} FETCH_HEAD^{commit}:refs/heads/${new_branch} |
| 82 | done |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 83 | |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 84 | # Create new download space |
| 85 | echo "Create new download space for \"${new_branch}\"" |
| 86 | aws s3 sync s3://trustedfirmware-prod-storage/tf-a s3://openci-trustedfirmware-storage-prod/tf-a-${new_branch} |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 87 | |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 88 | echo "CI Environment Setup for ${new_branch} branch Completed" > subject.txt |
| 89 | cat << EOF >email.txt |
| 90 | Hello, |
| 91 | The new LTS branch "${new_branch}" has been created in the following repositoris |
| 92 | ${repos} |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 93 | |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 94 | And the new download space is ready on ${DOWNLOAD_SERVER_URL}/tf-a-${new_branch} |
Arthur She | 1dc0306 | 2025-02-06 22:04:46 -0800 | [diff] [blame] | 95 | |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 96 | Please check the job log for the details |
| 97 | ${BUILD_URL}console |
Arthur She | 1dc0306 | 2025-02-06 22:04:46 -0800 | [diff] [blame] | 98 | |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 99 | EOF |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 100 | |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 101 | echo "--------- email body ----------" |
| 102 | cat email.txt |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 103 | publishers: |
| 104 | - conditional-publisher: |
| 105 | - condition-kind: file-exists |
Arthur She | 1dc0306 | 2025-02-06 22:04:46 -0800 | [diff] [blame] | 106 | on-evaluation-failure: dont-run |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 107 | condition-filename: email.txt |
| 108 | condition-basedir: workspace |
| 109 | action: |
Arthur She | 1dc0306 | 2025-02-06 22:04:46 -0800 | [diff] [blame] | 110 | - email-ext: |
| 111 | always: true |
Arthur She | 69c76dc | 2025-02-01 22:00:14 -0800 | [diff] [blame] | 112 | recipients: ${EMAIL_RECIPIENT} |
Chris Kay | 675db4f | 2025-06-24 14:14:34 +0100 | [diff] [blame] | 113 | subject: ${FILE,path="subject.txt"} |
| 114 | body: ${FILE,path="email.txt"} |