Make Build work without git
If you build elasticsearch without a git repository it was creating a null shortHash which was causing Elasticsearch not to be able to form transport connections. Closes #14748
This commit is contained in:
parent
e837140385
commit
0119caa4a6
|
@ -240,6 +240,10 @@ class BuildPlugin implements Plugin<Project> {
|
||||||
'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch,
|
'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch,
|
||||||
'X-Compile-Lucene-Version': VersionProperties.lucene,
|
'X-Compile-Lucene-Version': VersionProperties.lucene,
|
||||||
'Build-Date': ZonedDateTime.now(ZoneOffset.UTC))
|
'Build-Date': ZonedDateTime.now(ZoneOffset.UTC))
|
||||||
|
if (jarTask.manifest.attributes.containsKey('Change') == false) {
|
||||||
|
logger.warn('Building without git revision id.')
|
||||||
|
jarTask.manifest.attributes('Change': 'N/A')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,13 @@ import java.util.jar.JarInputStream;
|
||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Information about a build of Elasticsearch.
|
||||||
*/
|
*/
|
||||||
public class Build {
|
public class Build {
|
||||||
|
/**
|
||||||
|
* The current build of Elasticsearch. Filled with information scanned at
|
||||||
|
* startup from the jar.
|
||||||
|
*/
|
||||||
public static final Build CURRENT;
|
public static final Build CURRENT;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -56,6 +60,14 @@ public class Build {
|
||||||
shortHash = "Unknown";
|
shortHash = "Unknown";
|
||||||
date = "Unknown";
|
date = "Unknown";
|
||||||
}
|
}
|
||||||
|
if (shortHash == null) {
|
||||||
|
throw new IllegalStateException("Error finding the build shortHash. " +
|
||||||
|
"Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug.");
|
||||||
|
}
|
||||||
|
if (date == null) {
|
||||||
|
throw new IllegalStateException("Error finding the build date. " +
|
||||||
|
"Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug.");
|
||||||
|
}
|
||||||
|
|
||||||
CURRENT = new Build(shortHash, date);
|
CURRENT = new Build(shortHash, date);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue