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