public static String getDoradusVersion ( ) { String version = null ; try { //first read from the local git repository Git git = Git . open ( new File ( "../.git" ) ) ; String url = git . getRepository ( ) . getConfig ( ) . getString ( "remote" , "origin" , "url" ) ; instance ( ) . m_logger . info ( "Remote.origin.url: {}" , url ) ; if ( ! Utils . isEmpty ( url ) && url . contains ( "dell-oss/Doradus.git" ) ) { DescribeCommand cmd = git . describe ( ) ; version = cmd . call ( ) ; instance ( ) . m_logger . info ( "Doradus version found from git repo: {}" , version ) ; writeVersionToVerFile ( version ) ; } } catch ( Throwable e ) { instance ( ) . m_logger . info ( "failed to read version from git repo" ) ; } //if not found, reading from local file if ( Utils . isEmpty ( version ) ) { try { version = getVersionFromVerFile ( ) ; instance ( ) . m_logger . info ( "Doradus version found from doradus.ver file {}" , version ) ; } catch ( IOException e1 ) { version = null ; } } return version ; }
Get Doradus Version from git repo if it exists ; otherwise get it from the local doradus . ver file