vitess.io/vitess@v0.16.2/tools/build_version_flags.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2019 The Vitess Authors.
     4  # 
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  # 
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  # 
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
    18  source $DIR/shell_functions.inc
    19  
    20  # Normal builds run directly against the git repo, but when packaging (for example with rpms)
    21  # a tar ball might be used, which will prevent the git metadata from being available.
    22  # Should this be the case then allow environment variables to be used to source
    23  # this information instead.
    24  DEFAULT_BUILD_GIT_REV=$(git rev-parse HEAD)
    25  DEFAULT_BUILD_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
    26  
    27  echo "\
    28    -X 'vitess.io/vitess/go/vt/servenv.buildHost=$(hostname)' \
    29    -X 'vitess.io/vitess/go/vt/servenv.buildUser=$(whoami)' \
    30    -X 'vitess.io/vitess/go/vt/servenv.buildGitRev=${BUILD_GIT_REV:-$DEFAULT_BUILD_GIT_REV}' \
    31    -X 'vitess.io/vitess/go/vt/servenv.buildGitBranch=${BUILD_GIT_BRANCH:-$DEFAULT_BUILD_GIT_BRANCH}' \
    32    -X 'vitess.io/vitess/go/vt/servenv.buildTime=$(LC_ALL=C date)' \
    33    -X 'vitess.io/vitess/go/vt/servenv.jenkinsBuildNumberStr=${BUILD_NUMBER}' \
    34  "