diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 77ca2546a6..8da7d1b2ea 100755 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -16,8 +16,24 @@ set -euo pipefail echo "~~~ Increase receive network buffer size" sudo sysctl -w net.core.rmem_max=1048576 -echo "~~~ Setting up bazel environment" +# Export SCION_VERSION as environment variable, unless it's set from outside (e.g. as variable for this build) +# Note that this precommand hook runs even in "step zero" of the pipeline, where we `buildkite-agent upload'. +# With this, the SCION_VERSION can be interpolated by the agent throughout the pipeline yaml. +if [ -z ${SCION_VERSION+x} ]; then + echo "~~~ Export SCION_VERSION" + if [ "$BUILDKITE_PIPELINE_SLUG" == "scion" ]; then + # Shorten the git version to omit commit information, improving cache reuse. + # The format of git-version is "--" + # This will be shortened to "-modified-ci" + export SCION_VERSION=$(tools/git-version | sed 's/-.*/-modified-ci/') + else + export SCION_VERSION=$(tools/git-version) + fi + echo SCION_VERSION=${SCION_VERSION} +fi + +echo "~~~ Setting up bazel environment" if [ -z ${BAZEL_REMOTE_S3_ACCESS_KEY_ID+x} ]; then echo "S3 env not set, not starting bazel remote proxy" exit 0 @@ -30,12 +46,6 @@ rm -f $HOME/.bazelrc # --nostamp is required for better caching (only on non-release jobs). if [ "$BUILDKITE_PIPELINE_SLUG" == "scion" ]; then echo "build --nostamp" > $HOME/.bazelrc - if [ -z ${SCION_VERSION+x} ]; then - # Shorten the git version to omit commit information, improving cache reuse. - # The format of git-version is "--" - # This will be shortened to "-modified-ci" - export SCION_VERSION=$(tools/git-version | sed 's/-.*/-modified-ci/') - fi else echo "build --stamp" > $HOME/.bazelrc fi diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index be29e2a354..72c9c14cdb 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -7,15 +7,18 @@ steps: - bazel build --verbose_failures //docker:prod //docker:test key: build artifact_paths: - - "bazel-bin/scion.tar" - - "bazel-bin/scion-ci.tar" + - "scion_${SCION_VERSION}_amd64_linux.tar.gz" # Note: SCION_VERSION interpolated by buildkite agent uploading pipeline, see pre-command hook + - "scion-ci_${SCION_VERSION}_amd64_linux.tar.gz" plugins: - scionproto/metahook#v0.3.0: + pre-artifact: | + gzip --to-stdout bazel-bin/scion.tar > scion_${SCION_VERSION}_amd64_linux.tar.gz + gzip --to-stdout bazel-bin/scion-ci.tar > scion-ci_${SCION_VERSION}_amd64_linux.tar.gz post-artifact: | cat << EOF | buildkite-agent annotate --style "info" --context "binaries" #### Build outputs - - SCION binaries - - SCION test tools and utilities + - SCION binaries + - SCION test tools and utilities EOF retry: &automatic-retry automatic: @@ -25,28 +28,31 @@ steps: - wait - label: "Package :debian: :openwrt:" command: | - version=${SCION_VERSION:-$(tools/git-version)} - make dist-deb BFLAGS="--file_name_version=$${version}" - make dist-openwrt BFLAGS="--file_name_version=$${version}" - cd installables; - tar -chaf scion-deb-amd64.tar.gz *_$${version}_amd64.deb - tar -chaf scion-deb-arm64.tar.gz *_$${version}_arm64.deb - tar -chaf scion-deb-i386.tar.gz *_$${version}_i386.deb - tar -chaf scion-deb-armel.tar.gz *_$${version}_armel.deb - tar -chaf scion-openwrt-x86_64.tar.gz *_$${version}_x86_64.ipk + make dist-deb BFLAGS="--file_name_version=${SCION_VERSION}" + make dist-openwrt BFLAGS="--file_name_version=${SCION_VERSION}" artifact_paths: - - "installables/scion-*.tar.gz" + - "installables/scion_*.tar.gz" plugins: - scionproto/metahook#v0.3.0: + pre-artifact: | + set -x + pushd installables + tar -chaf scion_${SCION_VERSION}_deb_amd64.tar.gz *_${SCION_VERSION}_amd64.deb + tar -chaf scion_${SCION_VERSION}_deb_arm64.tar.gz *_${SCION_VERSION}_arm64.deb + tar -chaf scion_${SCION_VERSION}_deb_i386.tar.gz *_${SCION_VERSION}_i386.deb + tar -chaf scion_${SCION_VERSION}_deb_armel.tar.gz *_${SCION_VERSION}_armel.deb + tar -chaf scion_${SCION_VERSION}_openwrt_x86_64.tar.gz *_${SCION_VERSION}_x86_64.ipk + popd + ls installables post-artifact: | cat << EOF | buildkite-agent annotate --style "info" --context "packages" #### Packages :debian: - - amd64 - - arm64 - - i386 - - armel + - amd64 + - arm64 + - i386 + - armel #### Packages :openwrt: - - x86_64 + - x86_64 EOF key: dist retry: *automatic-retry