mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 15:56:45 -04:00
version file has been updated to include a travis commit and time of build.
This commit is contained in:
@@ -40,6 +40,7 @@ deploy:
|
|||||||
region: eu-west-1
|
region: eu-west-1
|
||||||
on: *2
|
on: *2
|
||||||
before_deploy:
|
before_deploy:
|
||||||
|
- ./scripts/update_version_file.sh
|
||||||
- zip -r notifications-api *
|
- zip -r notifications-api *
|
||||||
- mkdir -p dpl_cd_upload
|
- mkdir -p dpl_cd_upload
|
||||||
- mv notifications-api.zip dpl_cd_upload/notifications-api-$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER-$TRAVIS_COMMIT.zip
|
- mv notifications-api.zip dpl_cd_upload/notifications-api-$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER-$TRAVIS_COMMIT.zip
|
||||||
|
|||||||
@@ -121,13 +121,15 @@ def convert_to_number(value):
|
|||||||
|
|
||||||
|
|
||||||
def get_api_version():
|
def get_api_version():
|
||||||
_version_re = re.compile(r'__version__\s+=\s+(.*)')
|
build = 'n/a'
|
||||||
version = 'n/a'
|
build_time = "n/a"
|
||||||
dir_path = os.path.dirname(os.path.abspath(__file__))
|
try:
|
||||||
with open(os.path.join(dir_path, 'version.py'), 'rb') as f:
|
from app import version
|
||||||
version = str(ast.literal_eval(_version_re.search(
|
build = version.__build__
|
||||||
f.read().decode('utf-8')).group(1)))
|
build_time = version.__time__
|
||||||
return version
|
except:
|
||||||
|
pass
|
||||||
|
return build, build_time
|
||||||
|
|
||||||
|
|
||||||
def get_db_version():
|
def get_db_version():
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ status = Blueprint('status', __name__)
|
|||||||
@status.route('/_status', methods=['GET', 'POST'])
|
@status.route('/_status', methods=['GET', 'POST'])
|
||||||
def show_status():
|
def show_status():
|
||||||
from app import (get_api_version, get_db_version)
|
from app import (get_api_version, get_db_version)
|
||||||
|
build, build_time = get_api_version()
|
||||||
return jsonify(status="ok",
|
return jsonify(status="ok",
|
||||||
api_version=get_api_version(),
|
api_build=build,
|
||||||
|
api_built_time=build_time,
|
||||||
db_version=get_db_version()), 200
|
db_version=get_db_version()), 200
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
__version__ = '0.1.1'
|
__build__ = "12345"
|
||||||
|
__time__ = "2016-01-01:10:10:10"
|
||||||
|
|||||||
6
scripts/update_version_file.sh
Executable file
6
scripts/update_version_file.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Update the version file of the project from the Travis build details
|
||||||
|
#
|
||||||
|
sed -i -e "s/__build__ =.*/__build__ = \"$TRAVIS_COMMIT\"/g" ./app/version.py
|
||||||
|
sed -i -e "s/__time__ =.*/__time__ = \"$('date +%Y-%m-%d:%H:%M:%S')\"/g" ./app/version.py
|
||||||
Reference in New Issue
Block a user