Browse Source

AMBARI-5121. Set Ambari version at build time so that it is available as App.version from Ambari Web code. (yusaku)

Yusaku Sako 11 years ago
parent
commit
45383d3696
3 changed files with 32 additions and 0 deletions
  1. 1 0
      ambari-web/app/config.js
  2. 5 0
      ambari-web/pom.xml
  3. 26 0
      ambari-web/set-ambari-version.sh

+ 1 - 0
ambari-web/app/config.js

@@ -19,6 +19,7 @@
 
 var App = require('app');
 
+App.version = ''; // filled out by set-ambari-version.sh script
 App.testMode = (location.port == '3333'); // test mode is automatically enabled if running on brunch server
 App.testModeDelayForActions = 10000;
 App.skipBootstrap = false;

+ 5 - 0
ambari-web/pom.xml

@@ -96,6 +96,11 @@
                 <exec dir="${basedir}" executable="brunch" failonerror="false">
                   <arg value="build"/>
                 </exec>
+                <!-- sets Ambari version to make it accessible from code -->
+                <exec dir="${basedir}" executable="sh" failonerror="false">
+                  <arg value="${basedir}/set-ambari-version.sh"/>
+                  <arg value="${newVersion}"/>
+                </exec>
                 <!-- sets default stack and version to use for install -->
                 <exec dir="${basedir}" executable="sh" failonerror="false">
                   <arg value="${basedir}/set-default-stack-version.sh"/>

+ 26 - 0
ambari-web/set-ambari-version.sh

@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+if [ "$1" != '${newVersion}' ]
+then
+  echo "Setting Ambari version to $1"
+  sed "s/App.version.*=.*;/App.version = '$1';/" public/javascripts/app.js > public/javascripts/tmp.js; mv public/javascripts/tmp.js public/javascripts/app.js
+fi
+