blob: 610ba7941f25253e83f04d6bd302ab24169e2d99 [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:
12 - build-discarder:
13 days-to-keep: 15
14 parameters:
15 - string:
16 name: EMAIL_RECIPIENT
17 default: |
Arthur Shed7d4ac32025-02-06 22:12:41 -080018 bipin.ravi@arm.com, vwadekar@nvidia.com, yann.gautier@st.com, palmer@google.com, govindraj.raja@arm.com, arthur.she@linaro.org
Arthur She69c76dc2025-02-01 22:00:14 -080019 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 She06dfbee2025-02-20 22:43:11 -080066 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 She69c76dc2025-02-01 22:00:14 -080071 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 She136a1a02025-02-07 11:13:21 -080077 repos="hafnium/hafnium TF-A/tf-a-tests ci/tf-a-ci-scripts ci/tf-a-job-configs"
Arthur She69c76dc2025-02-01 22:00:14 -080078 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}\""
87 aws s3 sync s3://trustedfirmware-prod-storage/tf-a s3://trustedfirmware-prod-storage/tf-a-${new_branch}
88
Arthur She1dc03062025-02-06 22:04:46 -080089 echo "CI Environment Setup for ${new_branch} branch Completed" > subject.txt
Arthur She69c76dc2025-02-01 22:00:14 -080090 cat << EOF >email.txt
91 Hello,
92 The new LTS branch "${new_branch}" has been created in the following repositoris
93 ${repos}
94
Saheer Babu24fcaf92025-02-10 11:01:44 +000095 And the new download space is ready on ${DOWNLOAD_SERVER_URL}/tf-a-${new_branch}
Arthur She1dc03062025-02-06 22:04:46 -080096
97 Please check the job log for the details
98 ${BUILD_URL}console
99
Arthur She69c76dc2025-02-01 22:00:14 -0800100 EOF
101
102 echo "--------- email body ----------"
103 cat email.txt
104
105 publishers:
106 - conditional-publisher:
107 - condition-kind: file-exists
Arthur She1dc03062025-02-06 22:04:46 -0800108 on-evaluation-failure: dont-run
Arthur She69c76dc2025-02-01 22:00:14 -0800109 condition-filename: email.txt
110 condition-basedir: workspace
111 action:
Arthur She1dc03062025-02-06 22:04:46 -0800112 - email-ext:
113 always: true
Arthur She69c76dc2025-02-01 22:00:14 -0800114 recipients: ${EMAIL_RECIPIENT}
Arthur She1dc03062025-02-06 22:04:46 -0800115 subject: '${FILE,path="subject.txt"}'
116 body: '${FILE,path="email.txt"}'