in ossci/GitUtil.groovy [68:122]
static void resolveAndSaveParameters(StepContext context, String file) {
context.with {
// Capture the raw commit hash of GIT_COMMIT/GIT_MERGE_TARGET,
// such that they can be passed to downstream builds without
// risking that they are changed at the remote.
shell """#!/bin/bash
set -ex
rm -f "${file}" || true
# Expect the Git SCM plugin to have checked out the right commit if
# GIT_COMMIT is empty. Figure out what it points to so the commit hash
# can be passed to downstream builds.
if [ -z "\${GIT_COMMIT}" ]; then
echo "GIT_COMMIT=\$(git rev-parse HEAD)" >> "${file}"
else
echo "GIT_COMMIT=\$(git rev-parse \${GIT_COMMIT})" >> "${file}"
fi
if [ -n "\${GIT_MERGE_TARGET}" ]; then
echo "GIT_MERGE_TARGET=\$(git rev-parse \${GIT_MERGE_TARGET})" >> "${file}"
if test -x .jenkins/pytorch/dirty.sh; then
if .jenkins/pytorch/dirty.sh "\${GIT_MERGE_TARGET}" "\$(git rev-parse HEAD)"; then
echo "PYTORCH_CHANGED=1" >> "${file}"
else
echo "PYTORCH_CHANGED=0" >> "${file}"
fi
else
echo "PYTORCH_CHANGED=1" >> "${file}"
fi
if test -x .jenkins/caffe2/dirty.sh; then
if .jenkins/caffe2/dirty.sh "\${GIT_MERGE_TARGET}" "\$(git rev-parse HEAD)"; then
echo "CAFFE2_CHANGED=1" >> "${file}"
else
echo "CAFFE2_CHANGED=0" >> "${file}"
fi
else
# FIX ME
echo "CAFFE2_CHANGED=0" >> "${file}"
fi
else
# Assume the worst
echo "PYTORCH_CHANGED=1" >> "${file}"
# FIX ME
echo "CAFFE2_CHANGED=0" >> "${file}"
fi
# after parameters saved, try to prevent running out of disk space on trigger host
rm -rf .git
"""
}
}