diff --git a/tools/build-identifier.sh b/tools/build-identifier.sh index 7d3c82f8..cef6eeb6 100755 --- a/tools/build-identifier.sh +++ b/tools/build-identifier.sh @@ -22,15 +22,49 @@ if [[ -n ${RELEASE_TEST_BUILD_ID:-} ]] ; then exit 0 fi +if [[ "$PWD" =~ "operator" ]] && [[ -n ${KOKORO_GIT_COMMIT_connector_operator:-} ]] ; then + echo -n "${KOKORO_GIT_COMMIT_connector_operator}" + exit 0 +elif [[ "$PWD" =~ "proxy" ]] && [[ -n ${KOKORO_GIT_COMMIT_connector_proxy:-} ]] ; then + echo -n "${KOKORO_GIT_COMMIT_connector_proxy}" + exit 0 +elif [[ "$PWD" =~ "go" ]] && [[ -n ${KOKORO_GIT_COMMIT_connector_go:-} ]] ; then + echo -n "${KOKORO_GIT_COMMIT_connector_go}" + exit 0 +elif [[ "$PWD" =~ "python" ]] && [[ -n ${KOKORO_GIT_COMMIT_connector_python:-} ]] ; then + echo -n "${KOKORO_GIT_COMMIT_connector_python}" + exit 0 +elif [[ "$PWD" =~ "node" ]] && [[ -n ${KOKORO_GIT_COMMIT_connector_nodejs:-} ]] ; then + echo -n "${KOKORO_GIT_COMMIT_connector_nodejs}" + exit 0 +elif [[ "$PWD" =~ "java" ]] && [[ -n ${KOKORO_GIT_COMMIT_connector_java:-} ]] ; then + echo -n "${KOKORO_GIT_COMMIT_connector_java}" + exit 0 +elif [[ -n ${KOKORO_GIT_COMMIT_gemini_connector_tools:-} ]] ; then + echo -n "${KOKORO_GIT_COMMIT_gemini_connector_tools}" + exit 0 +elif [[ -n ${KOKORO_GIT_COMMIT:-} ]] ; then + echo -n "${KOKORO_GIT_COMMIT}" + exit 0 +fi + NOW=$(date -u "+%Y%m%dT%H%M" | tr -d "\n") -GIT_HEAD=$( git rev-parse HEAD | tr -d "\n") -if git diff HEAD --exit-code --quiet ; then - # git working dir is clean. - IMAGE_VERSION="$GIT_HEAD" +if jj root >/dev/null 2>&1; then + JJ_COMMIT=$(jj log -r @ -T "commit_id" --no-graph | tr -d "\n") + if jj status | grep -q "Working copy changes:"; then + IMAGE_VERSION="$JJ_COMMIT-dirty-${NOW}" + else + IMAGE_VERSION="$JJ_COMMIT" + fi else - # git working dir is dirty, append "dirty" and the timestamp - IMAGE_VERSION="$GIT_HEAD-dirty-${NOW}" + git config --global --add safe.directory "$PWD" 2>/dev/null || true + GIT_HEAD=$( git rev-parse HEAD | tr -d "\n" ) + if git diff HEAD --exit-code --quiet ; then + IMAGE_VERSION="$GIT_HEAD" + else + IMAGE_VERSION="$GIT_HEAD-dirty-${NOW}" + fi fi echo -n "$IMAGE_VERSION" diff --git a/tools/docker-build.sh b/tools/docker-build.sh index ce9fa5bb..7ebe1cd3 100755 --- a/tools/docker-build.sh +++ b/tools/docker-build.sh @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -eio pipefail +set -eo pipefail SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) ## diff --git a/tools/e2e_test_job.sh b/tools/e2e_test_job.sh index 563432ad..eebeb3f1 100755 --- a/tools/e2e_test_job.sh +++ b/tools/e2e_test_job.sh @@ -24,7 +24,11 @@ mkdir -p bin echo "Using installed gcloud" gcloud version -gcloud components install --quiet gke-gcloud-auth-plugin +if ! which gke-gcloud-auth-plugin >/dev/null 2>&1 ; then + gcloud components install --quiet gke-gcloud-auth-plugin +else + echo "gke-gcloud-auth-plugin already installed" +fi # Install helm if ! which helm ; then