blob: 417234488309177ffed35f3c55af72b6f1e0b86d [file] [log] [blame]
Arthur She69c76dc2025-02-01 22:00:14 -08001- 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 Kay675db4f2025-06-24 14:14:34 +010012 - build-discarder:
13 days-to-keep: 15
Arthur She69c76dc2025-02-01 22:00:14 -080014 parameters:
Chris Kay675db4f2025-06-24 14:14:34 +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
Arthur She69c76dc2025-02-01 22:00:14 -080021 wrappers:
Chris Kay675db4f2025-06-24 14:14:34 +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: ""
Arthur She69c76dc2025-02-01 22:00:14 -080032 triggers:
Chris Kay675db4f2025-06-24 14:14:34 +010033 - gerrit:
34 silent: true
35 server-name: review.trustedfirmware.org
36 projects:
Arthur She69c76dc2025-02-01 22:00:14 -080037 - branches:
38 - branch-compare-type: REG_EXP
Chris Kay675db4f2025-06-24 14:14:34 +010039 branch-pattern: lts-v.*
Arthur She69c76dc2025-02-01 22:00:14 -080040 project-compare-type: PLAIN
Chris Kay675db4f2025-06-24 14:14:34 +010041 project-pattern: TF-A/trusted-firmware-a
42 trigger-on:
Arthur She69c76dc2025-02-01 22:00:14 -080043 - ref-updated-event
Arthur She69c76dc2025-02-01 22:00:14 -080044 builders:
Chris Kay675db4f2025-06-24 14:14:34 +010045 - shell: |
46 echo "***************************************"
47 env | grep GERRIT
48 echo "***************************************"
49 - shell: |
50 #!/bin/bash
51 set -ex
Arthur She69c76dc2025-02-01 22:00:14 -080052
Chris Kay675db4f2025-06-24 14:14:34 +010053 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 She69c76dc2025-02-01 22:00:14 -080058
Chris Kay675db4f2025-06-24 14:14:34 +010059 _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 She69c76dc2025-02-01 22:00:14 -080063
Chris Kay675db4f2025-06-24 14:14:34 +010064 # 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 She69c76dc2025-02-01 22:00:14 -080074
Chris Kay675db4f2025-06-24 14:14:34 +010075 # 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 She69c76dc2025-02-01 22:00:14 -080083
Chris Kay675db4f2025-06-24 14:14:34 +010084 # 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 She69c76dc2025-02-01 22:00:14 -080087
Chris Kay675db4f2025-06-24 14:14:34 +010088 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 She69c76dc2025-02-01 22:00:14 -080093
Chris Kay675db4f2025-06-24 14:14:34 +010094 And the new download space is ready on ${DOWNLOAD_SERVER_URL}/tf-a-${new_branch}
Arthur She1dc03062025-02-06 22:04:46 -080095
Chris Kay675db4f2025-06-24 14:14:34 +010096 Please check the job log for the details
97 ${BUILD_URL}console
Arthur She1dc03062025-02-06 22:04:46 -080098
Chris Kay675db4f2025-06-24 14:14:34 +010099 EOF
Arthur She69c76dc2025-02-01 22:00:14 -0800100
Chris Kay675db4f2025-06-24 14:14:34 +0100101 echo "--------- email body ----------"
102 cat email.txt
Arthur She69c76dc2025-02-01 22:00:14 -0800103 publishers:
104 - conditional-publisher:
105 - condition-kind: file-exists
Arthur She1dc03062025-02-06 22:04:46 -0800106 on-evaluation-failure: dont-run
Arthur She69c76dc2025-02-01 22:00:14 -0800107 condition-filename: email.txt
108 condition-basedir: workspace
109 action:
Arthur She1dc03062025-02-06 22:04:46 -0800110 - email-ext:
111 always: true
Arthur She69c76dc2025-02-01 22:00:14 -0800112 recipients: ${EMAIL_RECIPIENT}
Chris Kay675db4f2025-06-24 14:14:34 +0100113 subject: ${FILE,path="subject.txt"}
114 body: ${FILE,path="email.txt"}