use of eu.bcvsolutions.idm.tool.exception.ReleaseException in project CzechIdMng by bcvsolutions.
the class AbstractReleaseManager method setFrontendVersion.
protected void setFrontendVersion(String fullVersionName) {
String newVersion = fullVersionName.toLowerCase();
//
for (String frontendModule : getFrontendModules(newVersion)) {
File modulePackage = new File(getFrontendModuleBasePath(frontendModule), "package.json");
Assert.isTrue(modulePackage.exists(), String.format("Frontend module [%s] not found on filesystem.", frontendModule));
//
try {
ObjectNode json = (ObjectNode) getPackageJson(modulePackage);
json.put("version", newVersion);
//
try (FileOutputStream outputStream = new FileOutputStream(modulePackage)) {
JsonGenerator jGenerator = getMapper().getFactory().createGenerator(outputStream, JsonEncoding.UTF8);
getMapper().writer(getPrettyPrinter()).writeValue(jGenerator, json);
jGenerator.close();
//
LOG.info("Frontend module [{}] version set to [{}]", frontendModule, newVersion);
} catch (Exception ex) {
throw new ReleaseException(ex);
}
} catch (Exception ex) {
throw new ReleaseException(ex);
}
}
}
use of eu.bcvsolutions.idm.tool.exception.ReleaseException in project CzechIdMng by bcvsolutions.
the class AbstractReleaseManager method revertVersion.
@Override
public String revertVersion() {
gitSwitchBranch(getDevelopBranch());
//
String forVersion = getCurrentBackendModuleVersion(getRootBackendModule());
// checkout doesn't support wildcards, don't know why ...
List<String> allProjectFiles = Stream.concat(getBackendModules(forVersion).stream().map(moduleName -> {
return String.format("%s/pom.xml", getBackendModuleRelativePath(moduleName));
}), getFrontendModules(forVersion).stream().map(moduleName -> {
return String.format("%s/package.json", getFrontendModuleRelativePath(moduleName));
})).collect(Collectors.toList());
//
try {
gitCheckout(allProjectFiles);
//
String currentVersion = getCurrentVersion();
LOG.info("Project files (pom.xml, package.json) reverted. Current version [{}].", currentVersion);
return currentVersion;
} catch (Exception ex) {
throw new ReleaseException("Revert project files failed", ex);
}
}
use of eu.bcvsolutions.idm.tool.exception.ReleaseException in project CzechIdMng by bcvsolutions.
the class AbstractReleaseManager method getCurrentBackendModuleVersion.
protected String getCurrentBackendModuleVersion(String moduleName) {
File modulePackage = new File(String.format("%s/pom.xml", getBackendModuleBasePath(moduleName)));
Assert.isTrue(modulePackage.exists(), String.format("Backend module [%s] not found on filesystem.", moduleName));
//
try {
XmlMapper xmlMapper = new XmlMapper();
JsonNode json = xmlMapper.readTree(modulePackage);
//
String currentVersion = null;
JsonNode versionNode = json.get("version");
if (versionNode == null) {
JsonNode parentNode = json.get("parent");
if (parentNode != null) {
versionNode = parentNode.get("version");
}
}
if (versionNode != null) {
currentVersion = versionNode.textValue();
}
//
return currentVersion;
} catch (Exception ex) {
throw new ReleaseException(ex);
}
}
use of eu.bcvsolutions.idm.tool.exception.ReleaseException in project CzechIdMng by bcvsolutions.
the class AbstractReleaseManager method getCurrentFrontendModuleVersion.
protected String getCurrentFrontendModuleVersion(String moduleName) {
File modulePackage = new File(getFrontendModuleBasePath(moduleName), "package.json");
Assert.isTrue(modulePackage.exists(), String.format("Frontend module [%s] not found on filesystem.", moduleName));
//
try {
JsonNode json = getPackageJson(modulePackage);
String currentVersion = json.get("version").textValue();
//
return currentVersion;
} catch (Exception ex) {
throw new ReleaseException(ex);
}
}
use of eu.bcvsolutions.idm.tool.exception.ReleaseException in project CzechIdMng by bcvsolutions.
the class AbstractReleaseManager method release.
@Override
public String release(String releaseVersion, String newDevelopVersion) {
// no local changes
if (!gitIsClean()) {
throw new ReleaseException("Local changes found - push or revert changes before release");
}
// switch develop
gitSwitchBranch(getDevelopBranch());
gitPull();
//
if (StringUtils.isEmpty(releaseVersion)) {
releaseVersion = getVersionNumber(getCurrentVersion());
}
//
LOG.info("Release version [{}] ...", releaseVersion);
//
// set stable version
setVersion(releaseVersion);
if (checkChanges() > 0) {
// prevent to create empty commit
gitAddAll();
gitCommit(String.format("Release version [%s] - prepare", releaseVersion));
}
// deploy - its saver than merge stable into master (this takes long time and conflict can occurs)
deploy();
//
if (checkChanges() > 0) {
// prevent to create empty commit
// package-lock is changed after build + deploy => we need to commit it into tag / master
gitAddAll();
gitCommit(String.format("Release version [%s] - alfter build", releaseVersion));
}
// create tag
gitCreateTag(releaseVersion);
// merge into master, if branch is given
// sometimes merge is not needed (e.g. when some old hotfix branch is released - set null)
String masterBranch = getMasterBranch();
if (StringUtils.isNotEmpty(masterBranch)) {
gitSwitchBranch(masterBranch);
gitPull();
// merge develop into master - conflict can occurs => just this and next step should be repeated.
gitMerge(getDevelopBranch());
// switch develop
gitSwitchBranch(getDevelopBranch());
}
// set new develop version version
if (StringUtils.isEmpty(newDevelopVersion)) {
newDevelopVersion = getNextSnapshotVersionNumber(releaseVersion, null);
}
setVersion(newDevelopVersion);
if (checkChanges() > 0) {
// prevent to create empty commit
gitAddAll();
gitCommit(String.format("New develop version [%s]", newDevelopVersion));
}
//
LOG.info("Version released [{}]. New development version [{}].", releaseVersion, newDevelopVersion);
LOG.info("Branches [{}], [{}] and tag [{}] are prepared to push into origin.", getDevelopBranch(), getMasterBranch(), releaseVersion);
//
return releaseVersion;
}
Aggregations