Use payload.env instead of forwarding variables manually

This commit is contained in:
Reuben Morais 2020-12-18 16:40:07 +00:00
parent bb1ad00194
commit 4723de25bf
2 changed files with 11 additions and 27 deletions

View File

@ -49,7 +49,14 @@ tasks:
taskclusterProxy: true
env:
TC_DECISION_SHA: ef67832e6657f43e139a10f37eb326a7d9d96dad
TASK_ID: ${metadata.task_id}
GITHUB_HEAD_USER_LOGIN: ${metadata.github.login}
GITHUB_HEAD_USER_EMAIL: ${metadata.github.login}@users.noreply.github.com
GITHUB_EVENT: ${metadata.github.action}
GITHUB_HEAD_REPO_URL: ${metadata.github.clone_url}
GITHUB_HEAD_BRANCH: ${metadata.github.ref}
GITHUB_HEAD_REF: ${metadata.github.ref}
GITHUB_HEAD_SHA: ${metadata.github.sha}
command:
- "/bin/bash"
@ -62,15 +69,7 @@ tasks:
cd /home/build-user/ &&
echo -e "#!/bin/bash\nset -xe\nenv && id && mkdir ~/DeepSpeech/ && git clone --quiet ${metadata.github.clone_url} ~/DeepSpeech/ds/ && cd ~/DeepSpeech/ds && git checkout --quiet ${metadata.github.ref}" > /tmp/clone.sh && chmod +x /tmp/clone.sh &&
sudo -H -u build-user /bin/bash /tmp/clone.sh &&
sudo -H -u build-user --preserve-env /bin/bash /home/build-user/DeepSpeech/ds/taskcluster/tc-schedule.sh \
TASK_ID=${metadata.task_id} \
GITHUB_HEAD_USER_LOGIN=${metadata.github.login} \
GITHUB_HEAD_USER_EMAIL=${metadata.github.login}@users.noreply.github.com \
GITHUB_EVENT=${metadata.github.action} \
GITHUB_HEAD_REPO_URL=${metadata.github.clone_url} \
GITHUB_HEAD_BRANCH=${metadata.github.ref} \
GITHUB_HEAD_REF=${metadata.github.ref} \
GITHUB_HEAD_SHA=${metadata.github.sha}
sudo -H -u build-user --preserve-env /bin/bash /home/build-user/DeepSpeech/ds/taskcluster/tc-schedule.sh
artifacts:
"public":
type: "directory"

View File

@ -1,11 +1,6 @@
#!/bin/bash
set -ex
# Set environment variables passed in arguments
for line in $@; do
eval "$line"
done
curdir=$(dirname "$0")/
pip3 install --quiet --user --upgrade pip
@ -40,19 +35,9 @@ GITHUB_HEAD_USER_EMAIL="email" \
python3 ${curdir}/tc-decision.py --dry
# Create a new env variable for usage in TaskCluster .yml files
GITHUB_HEAD_BRANCHORTAG="${GITHUB_HEAD_BRANCH}${GITHUB_HEAD_TAG}"
export GITHUB_HEAD_BRANCHORTAG="${GITHUB_HEAD_BRANCH}${GITHUB_HEAD_TAG}"
# Quick hack because tc-decision uses GITHUB_HEAD_BRANCH
GITHUB_HEAD_BRANCH="${GITHUB_HEAD_BRANCH}${GITHUB_HEAD_TAG}"
export GITHUB_HEAD_BRANCH="${GITHUB_HEAD_BRANCH}${GITHUB_HEAD_TAG}"
# Forward all variables to tc-decision.py
GITHUB_EVENT="$GITHUB_EVENT" \
TASK_ID="$TASK_ID" \
GITHUB_HEAD_BRANCHORTAG="${GITHUB_HEAD_BRANCHORTAAG}" \
GITHUB_HEAD_BRANCH="${GITHUB_HEAD_BRANCH}" \
GITHUB_HEAD_REF="$GITHUB_HEAD_REF" \
GITHUB_HEAD_SHA="$GITHUB_HEAD_SHA" \
GITHUB_HEAD_REPO_URL="$GITHUB_HEAD_REPO_URL" \
GITHUB_HEAD_USER_LOGIN="$GITHUB_HEAD_USER_LOGIN" \
GITHUB_HEAD_USER_EMAIL="$GITHUB_HEAD_USER_EMAIL" \
python3 ${curdir}/tc-decision.py