Class PlatformReleaseService
java.lang.Object
fr.paris.lutece.plugins.releaser.service.platform.PlatformReleaseService
Release of the Lutece platform, step by step : campaign lifecycle, preparation of a step in a transient
Site (aggregate POM, components,
target versions by release type), propagation of the released versions to the next steps, plan sent to Jenkins, CSV export.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat is wrong with the credentials of the user for a Git platform. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyPipelineParameters(PlatformRelease campaign, int nStepNumber, PlatformReleasePlan plan) Copies the pipeline parameters chosen on the screen into the plan of a step before it is sent.static voidapplyReleaseType(Component component, PlatformReleaseType releaseType) Selects, among the next versions of a component to release, the one matching the release type.static voidapplyReleaseType(Site site, PlatformReleaseType releaseType) Selects, among the next versions of an aggregate, the one matching the release type.static voidattachBuild(PlatformReleaseStep step, String strBuildUrl, int nBuildNumber) Records the Jenkins build of a running step, once the queue has started it.static PlatformReleasePlanbuildPlan(PlatformRelease campaign, int nStepNumber, Site site, boolean bDryRun, Locale locale) Builds the plan of a step : the flagged components that must be released, with the same rule as a site release (Component.shouldBeReleased(): a component whose snapshot is not the last one available, a downgrade or a theme is not released), plus the components released from a tag, in release order, then the aggregate with the version updates to apply to its POM.static PlatformReleasePlanbuildPlan(PlatformRelease campaign, int nStepNumber, Site site, PlatformStepMode mode, Locale locale) Builds the plan of a step for a release, a simulation or a verification, seebuildPlan(PlatformRelease, int, Site, boolean, Locale).static voidcancelDowngradeComponent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId) Cancels the downgrade of a component of a step, its target being then chosen again for the release type of the step.static voidcancelUpgradeComponent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId) Cancels the use of a newer release for a component of a step, and forgets the choice.static booleancanPrepareStep(PlatformRelease campaign, int nStepNumber) Whether a step can be prepared : the first step always, the others once the previous step is completed (success or skipped) and the step itself is not already running or done ; the last step also needs the export of the campaign to have been checked.static booleancanSkipStep(PlatformRelease campaign, int nStepNumber) Whether a step can be skipped : global-pom, site-pom and core may have nothing to release ; the platform plugins and starters steps are the purpose of the campaign and can never be skipped.static booleancanVerify(PlatformStepCode code) Whether the components of a step can be verified : only the step pipeline has a verification mode, not the lutece-platform pipeline of the last step.static booleancanVerifyExport(PlatformRelease campaign) Whether the CSV export may be marked as verified : only once step 4 succeeded and while step 5 has not been run.static voidcheckComponentBranch(Component component, int nCoreMajor, ReleaserUser user, Locale locale) Checks that the branch of a component to release carries what the plan expects, before anything is sent to the pipeline : the version of its POM must be the SNAPSHOT referenced by the aggregate, and a parent of the core line (lutece-global-pom, lutece-site-pom) must be of the core version of the campaign.static StringcheckLaunchPermissions(Site site, ReleaserUser user) Checks, before a real launch, that the user may push on the GitHub repositories the step will touch : the aggregate, always committed, and every component to release.static StringcheckMasterBranches(PlatformReleasePlan plan, ReleaserUser user, Locale locale) Checks, before a real launch, that the master branch each released resource will be merged into exists on its repository : the pipeline merges after the deploy, a missing branch would leave the artifacts published and the build failed without rollback.static booleancheckReleasable(Component component, int nCoreMajor, Locale locale) Turns into a blocking anomaly the cases where a component cannot be released by this campaign, whatever the user does : a theme, never released from here ; a SNAPSHOT of the aggregate POM ahead of the last one published in Nexus, which the pipeline could not release ; a default branch built for another core version than the campaign.static voidcompleteStep(PlatformRelease campaign, PlatformReleaseStep step, PlatformStepResult result, String strJenkinsResult) Records the success of a step and unlocks the next one.countVerificationStatuses(Map<String, String> mapStatuses) Counts the resources of each verification status.static PlatformReleasecreatePlatformRelease(String strName, PlatformReleaseType releaseType, int nCoreMajor, String strUserName) Creates a campaign with its 5 steps : the first one ready, the others to do.static voidcycleTargetVersion(PlatformRelease campaign, int nStepNumber, Site site) Moves the target version of the aggregate of a step to the next candidate of the release type of the step.static voidcycleTargetVersion(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId) Moves the target version of a component of a step to the next candidate of the release type of the step, unlike the site screen which goes through every candidate.static intdeselectSnapshotComponents(PlatformRelease campaign, int nStepNumber, Site site) Unflags every component flagged as to be released in a step and not released by a previous attempt, the reverse ofselectSnapshotComponents(PlatformRelease, int, Site, ReleaserUser, Locale).static voiddowngradeComponent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId) Uses, instead of releasing it, the last release of a component of a step, and keeps the choice.static StringexportCsv(PlatformRelease campaign) Exports the plans of every step of a campaign, components then aggregate, one line per resource.static voidfailStep(PlatformRelease campaign, PlatformReleaseStep step, String strJenkinsResult) Records the failure of a step : the campaign stays on this step, which can be prepared and sent again.static voidfailStep(PlatformRelease campaign, PlatformReleaseStep step, String strJenkinsResult, PlatformStepResult partialResult) Records the failure of a step with the partial report of the pipeline : the components released before the failure are stored, so that the next attempt of the step does not release them again.static voidfinishDryRun(PlatformRelease campaign, PlatformReleaseStep step, String strJenkinsResult, String strReport) Records the end of a dry run : nothing was released, the step is ready again and keeps the Jenkins result and the report of the build for information.static voidfinishVerification(PlatformRelease campaign, PlatformReleaseStep step, String strJenkinsResult, String strReport, Map<String, PlatformResourceVerification> mapVerifications) Ends a verification : the step goes back to READY like after a simulation, the verifications read from the pipeline replace the previous ones of the same resources and keep the others (a retest of some components only), the report of the verification is the report of the step.getBranchHeads(PlatformReleaseStep step, Site site, ReleaserUser user) Reads the current commit of the branch of every resource verified OK or with a warning, in parallel and with the credentials of the user : a resource whose branch moved since its verification is stale.getCredentialProblems(Site site, ReleaserUser user) Diagnoses the credentials of the user for the hosts of the components of a step : missing when none was given, refused when every component of the host had its branch listing rejected for authentication and none succeeded.static StringgetDeployRepository(RepositoryType repositoryType, String strPrivateRepositoryUrl) Returns the Nexus repository a resource is deployed to : the private one for GitLab, the one of the POM for the others.getEffectivePipelineParameters(PlatformRelease campaign, int nStepNumber, Site site) Returns the pipeline parameters shown on the screen of a step :the chosen ones (target, SNAPSHOT tolerance), completed with the values computed from the campaign and the prepared aggregate (core, next snapshot), shown for information only.getFromTagComponents(int nIdPlatformRelease, int nStepNumber, Site site) Returns the components of a step released in stable from the tag of the beta or RC they stayed in.Returns the flagged components whose POM SNAPSHOT is behind the last one published in Nexus, offered the "release the last SNAPSHOT" choice.getLatestSnapshotComponents(int nIdPlatformRelease, int nStepNumber, Site site) Returns the components of a step for which the "release the last published SNAPSHOT" choice is active.static StringgetMasterBranch(String strBranchReleaseFrom, String strTargetVersion) Returns the master branch to merge a released resource into : none for a beta or RC target version, whatever the type of the campaign (a stable component may be released in a beta campaign and a beta component in a stable one), the master counterpart of the release branch otherwise.static List<RepositoryType>getNeededRepositoryTypes(Site site) Returns the repository types a step needs credentials for : the host of its aggregate, then the hosts of its components, in order.getPipelineParameters(int nIdPlatformRelease, int nStepNumber) Returns the pipeline parameters chosen on the screen of a step, by Jenkins parameter name (only the ones set).Returns the status of each resource as last verified, "groupId:artifactId" to OK, TO_FIX or WARNING, without comparing to the current target versions : for the summary of the campaign page, where the steps are not prepared.getResourcesToConfirm(Map<String, String> mapStatuses) Returns the resources a release would be launched with although they are not verified, to fix or stale : the warnings are accepted.getStayedInPrereleaseComponents(PlatformRelease campaign, int nStepNumber, Site site) Returns the components of a step not to release that stayed in beta or RC, with the campaign that released their beta or RC when known.static PlatformReleaseStepgetStep(PlatformRelease campaign, int nStepNumber) Returns a step of a campaign, the step 0 included.static Map<PlatformStepCode,String> getStepBranches(int nCoreMajor) Returns the release branch of every aggregate for a core version, as deduced by the campaign (shown when a campaign is created).static StringgetStepBranchOverride(int nIdPlatformRelease, int nStepNumber) Returns the branch chosen on the screen of a step for its aggregate, in place of the one deduced from the core.static StringgetStepLockReason(PlatformRelease campaign, int nStepNumber, boolean bSkip) Returns why a step cannot be prepared or skipped, as the i18n key of the message to show.static PlatformReleaseTypegetStepReleaseType(PlatformRelease campaign, PlatformStepCode code) Returns the release type of a step : stable for the stable-only steps, the campaign type otherwise.static StringgetStepReport(PlatformRelease campaign, int nStepNumber) Returns the report of the last build of a step, simulation included.static RepositoryTypegetStepRepositoryType(int nStepNumber) Returns the repository type of the aggregate of a step, the credentials asked before the step can be prepared.static StringIdentifies the state of a step as seen by a prepared screen : the screen must be rebuilt when the step was run meanwhile, otherwise components published by a failed attempt would be sent again.static Map<String,PlatformResourceVerification> Returns the last verification of each resource of a step, "groupId:artifactId" to verification.static StringgetTestedCommit(PlatformResourceVerification verification, String strTargetVersion) Returns the commit whose tests passed at the verification of a resource, so that the release does not run them again on the same commit.getUndecidedUntestedResources(PlatformReleaseStep step, Map<String, String> mapStatuses) Returns the resources a release cannot be launched with : to fix for commits made after their last beta or RC, without a decision.static Map<String,PlatformUntestedDecision> Returns the decisions of a step that still hold, "groupId:artifactId" to decision.static StringReturns the date of the last verification of a step.getVerificationStatuses(PlatformReleaseStep step, Site site, Map<String, String> mapBranchHeads) Returns the verification status of each resource to release in a prepared step, "groupId:artifactId" to OK, TO_FIX, WARNING, NOT_VERIFIED or STALE : the components to release, then the aggregate.static booleanhasSelectableSnapshotComponents(PlatformRelease campaign, int nStepNumber, Site site) Tells whether a step still has components thatselectSnapshotComponents(PlatformRelease, int, Site, ReleaserUser, Locale)would flag.static booleanTells whether the aggregate of a step may be released from a beta or RC tag : only the core, the other aggregates being stable only (global-pom, site-pom) or not released by their step (lutece-platform).static booleanisMergedIntoMaster(String strTargetVersion) Whether a released version is merged into the master branch : only a stable version is, never a beta or RC one.static booleanisRunning(PlatformRelease campaign) Whether a step of the campaign is being run : a Jenkins build is in progress and the campaign must not be removed.static booleanWhether the build of a running step is followed by a task of this webapp.static booleanisValidReleaseTarget(String strReleaseTarget, Site site) Tells whether a release target sent for the lutece-platform pipeline is one the screen offers : all, or a module of the aggregate.static booleanWhether a step is running a verification of its components.static voidlaunchStep(PlatformRelease campaign, int nStepNumber, PlatformReleasePlan plan, ReleaserUser user, Locale locale) Launches a step : records the plan, marks the step running and hands the Jenkins dialog over to a background task of the release thread pool.static voidloadParentVersions(PlatformRelease campaign, int nStepNumber, Site site) Proposes, for the aggregate and every component of a step whose parent is a POM of the core line (lutece-global-pom, lutece-site-pom), the last version of that parent when it is newer than the declared one : the version released by the campaign at the step of that parent, otherwise the last release published in Nexus for the core version of the campaign.static SiteloadStepAggregate(PlatformRelease campaign, int nStepNumber, ReleaserUser user, Locale locale) Loads the aggregate of a step in a transient site : clone, POM, components according to the step source, remote informations, target versions according to the release type, versions already released by the previous steps.static voidmarkExportVerified(int nIdPlatformRelease) Records that the export of the plugins step was checked by a human : only that flag is written, on a fresh copy of the campaign.static intRearms every step left RUNNING by a previous run of the webapp, the step 0 of any campaign included.static booleanrearmStep(PlatformRelease campaign, int nStepNumber) Rearms a running step that nobody follows : its known Jenkins build is followed again until its result is recorded ; without a known build the step is failed, so that it can be prepared and launched again.static voidrecordFollowUpGivenUp(PlatformReleaseStep step, String strResult) Records the cause of a lost follow-up on a running step : only the Jenkins result text is written, the status stays RUNNING so that the step can be rearmed on its build.static voidreleaseFromTag(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId, ReleaserUser user, Locale locale) Flags a component that stayed in beta or RC as to be released in stable from its tag, found on its repository ("artifactId-version", otherwise "vversion").static voidremovePlatformRelease(int nIdPlatformRelease) Removes a campaign, its steps and the "to be released" flags of its components.static booleanremovePlatformReleaseIfIdle(int nIdPlatformRelease) Removes a campaign unless one of its steps, the step 0 included, is running : checked and done under the launch lock.static voidrestrictPlan(PlatformReleasePlan plan, Set<String> setCoordinates) Restricts a verification plan to some resources : the components not listed are removed, the aggregate too when it is not listed.static voidsavePipelineParameters(int nIdPlatformRelease, int nStepNumber, Map<String, String> mapParameters) Saves the pipeline parameters chosen on the screen of a step ; a null value removes the parameter.static voidsaveStepBranch(int nIdPlatformRelease, int nStepNumber, String strBranch) Saves the branch chosen on the screen of a step for its aggregate ; null restores the branch deduced from the core.static intselectSnapshotComponents(PlatformRelease campaign, int nStepNumber, Site site, ReleaserUser user, Locale locale) Flags every component of a step that can be released as to be released : still in SNAPSHOT, not flagged yet, not released by a previous attempt, without blocking anomaly and without pending upgrade, the same rule as the "add" button of a component line.static StringselectTargetVersion(List<String> listTargetVersions, String strDefaultVersion, PlatformReleaseType releaseType) Selects the version matching a release type in a list of candidate versions : the first RC for RC, the first beta for beta, the first plain version otherwise.static booleansetUntestedDecision(PlatformReleaseStep step, String strCoordinates, String strUserName, boolean bAccept, boolean bFromTag) Records the decision to release a resource from the SNAPSHOT despite its untested commits, or from the beta or RC tag they follow, on the commit of its last verification, or cancels it.static voidskipStep(PlatformRelease campaign, int nStepNumber) Skips a step and unlocks the next one.sortComponents(List<Component> listComponents) Orders the components of a step for a sequential release : libraries, then the other artifacts, then plugins, then modules.static voidstartStep(PlatformRelease campaign, PlatformReleaseStep step, PlatformReleasePlan plan) Records the start of a step : the plan sent to Jenkins, the step and the campaign running.static voidtoggleProjectComponent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId, ReleaserUser user, Locale locale) Toggles the "to be released" flag of a component of a step, like a site component.static voidupdateBugtrackerVersions(PlatformReleaseStep step, PlatformReleasePlan plan, PlatformStepResult result) Updates the bugtracker for the resources published by a build, as the component workflow does after a classic release : the Redmine version of each published component is closed and the next one created, a beta or RC leaves it untouched, a component without project is reported.static voidupgradeAllParents(PlatformRelease campaign, int nStepNumber, Site site) Chooses the upgrade of the parent POM of the aggregate and of every flagged component of a step whose parent has a newer version.static voidupgradeComponent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId) Uses the newer release published in Nexus for a component of a step, and keeps the choice.static voidupgradeParent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId, boolean bUpgrade) Chooses, or gives up, the upgrade of the parent POM of a resource of a step to its last version.static voiduseLatestSnapshot(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId, boolean bUse, ReleaserUser user, Locale locale) Releases a flagged component from the last SNAPSHOT published in Nexus instead of the older SNAPSHOT still referenced by the aggregate POM, or goes back to the POM version.static voidusePomVersion(PlatformRelease campaign, int nStepNumber, Site site, boolean bParent, String strChoice, Locale locale) Records the choice made for a version of the platform POM : "keep" to leave the POM as it is, a version to let the pipeline set it before the release, null to forget the choice.
-
Field Details
-
VERIFICATION_NOT_VERIFIED
Verification status of a resource never verified, or verified for another version than its current target.- See Also:
-
VERIFICATION_STALE
Verification status of a resource that passed on a commit its branch no longer points to.- See Also:
-
-
Method Details
-
createPlatformRelease
public static PlatformRelease createPlatformRelease(String strName, PlatformReleaseType releaseType, int nCoreMajor, String strUserName) Creates a campaign with its 5 steps : the first one ready, the others to do.- Parameters:
strName- the campaign namereleaseType- the release type (stable, beta, RC)nCoreMajor- the core version (7 or 8)strUserName- the creator- Returns:
- the created campaign, with its steps
-
removePlatformRelease
public static void removePlatformRelease(int nIdPlatformRelease) Removes a campaign, its steps and the "to be released" flags of its components.- Parameters:
nIdPlatformRelease- the campaign id
-
getStep
Returns a step of a campaign, the step 0 included.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step number- Returns:
- the step, or null if not found
-
canPrepareStep
Whether a step can be prepared : the first step always, the others once the previous step is completed (success or skipped) and the step itself is not already running or done ; the last step also needs the export of the campaign to have been checked.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step number- Returns:
- true if the step can be prepared
-
getStepLockReason
Returns why a step cannot be prepared or skipped, as the i18n key of the message to show.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step numberbSkip- true when the step is to be skipped- Returns:
- the message key, null when the step can be prepared or skipped
-
canSkipStep
Whether a step can be skipped : global-pom, site-pom and core may have nothing to release ; the platform plugins and starters steps are the purpose of the campaign and can never be skipped.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step number- Returns:
- true if the step can be skipped
-
skipStep
Skips a step and unlocks the next one.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step number
-
removePlatformReleaseIfIdle
public static boolean removePlatformReleaseIfIdle(int nIdPlatformRelease) Removes a campaign unless one of its steps, the step 0 included, is running : checked and done under the launch lock.- Parameters:
nIdPlatformRelease- the campaign id- Returns:
- true when removed, false when running
-
markExportVerified
public static void markExportVerified(int nIdPlatformRelease) Records that the export of the plugins step was checked by a human : only that flag is written, on a fresh copy of the campaign.- Parameters:
nIdPlatformRelease- the campaign id
-
launchStep
public static void launchStep(PlatformRelease campaign, int nStepNumber, PlatformReleasePlan plan, ReleaserUser user, Locale locale) throws IOException Launches a step : records the plan, marks the step running and hands the Jenkins dialog over to a background task of the release thread pool.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step numberplan- the plan to senduser- the releaser user, whose credentials are sent to the pipeline : it clones and pushes with themlocale- the locale of the messages- Throws:
IOException- if the plan cannot be serialized
-
checkMasterBranches
public static String checkMasterBranches(PlatformReleasePlan plan, ReleaserUser user, Locale locale) Checks, before a real launch, that the master branch each released resource will be merged into exists on its repository : the pipeline merges after the deploy, a missing branch would leave the artifacts published and the build failed without rollback. The branches of a repository are listed once.- Parameters:
plan- the plan about to be sentuser- the releaser user, for the repository credentialslocale- the locale of the message- Returns:
- the message refusing the launch, null when every master branch exists
-
checkLaunchPermissions
Checks, before a real launch, that the user may push on the GitHub repositories the step will touch : the aggregate, always committed, and every component to release. The pipeline pushes with the credentials of the user, this check saves a failed build and its rollback.- Parameters:
site- the transient site of the stepuser- the releaser user- Returns:
- the message refusing the launch, null when every push is allowed
-
startStep
public static void startStep(PlatformRelease campaign, PlatformReleaseStep step, PlatformReleasePlan plan) throws IOException Records the start of a step : the plan sent to Jenkins, the step and the campaign running.- Parameters:
campaign- the campaignstep- the stepplan- the plan sent- Throws:
IOException- if the plan cannot be serialized
-
attachBuild
Records the Jenkins build of a running step, once the queue has started it.- Parameters:
step- the stepstrBuildUrl- the Jenkins build URLnBuildNumber- the Jenkins build number
-
finishDryRun
public static void finishDryRun(PlatformRelease campaign, PlatformReleaseStep step, String strJenkinsResult, String strReport) throws IOException Records the end of a dry run : nothing was released, the step is ready again and keeps the Jenkins result and the report of the build for information.- Parameters:
campaign- the campaignstep- the stepstrJenkinsResult- the Jenkins build resultstrReport- the report of the build, null when none could be read- Throws:
IOException- if the report cannot be serialized
-
finishVerification
public static void finishVerification(PlatformRelease campaign, PlatformReleaseStep step, String strJenkinsResult, String strReport, Map<String, PlatformResourceVerification> mapVerifications) throws IOExceptionEnds a verification : the step goes back to READY like after a simulation, the verifications read from the pipeline replace the previous ones of the same resources and keep the others (a retest of some components only), the report of the verification is the report of the step. For the step 0, the checks of the pipeline are added to the instant checks of the census and its report follows the census one.- Parameters:
campaign- the campaign, loaded with its stepsstep- the stepstrJenkinsResult- the Jenkins result of the verification buildstrReport- the text report of the build, null when unreadablemapVerifications- the verification of each resource, "groupId:artifactId" to verification, null when unreadable- Throws:
IOException- if the result cannot be serialized
-
updateBugtrackerVersions
public static void updateBugtrackerVersions(PlatformReleaseStep step, PlatformReleasePlan plan, PlatformStepResult result) Updates the bugtracker for the resources published by a build, as the component workflow does after a classic release : the Redmine version of each published component is closed and the next one created, a beta or RC leaves it untouched, a component without project is reported. Idempotent : a version already closed or already created is left as is. Never fails the step : the outcome is appended to the report of the step. Nothing is done for a simulation nor for the platform pipeline, whose aggregate is not tracked.- Parameters:
step- the step, its result storedplan- the plan sent with the buildresult- the result of this build, null when none could be read
-
recordFollowUpGivenUp
Records the cause of a lost follow-up on a running step : only the Jenkins result text is written, the status stays RUNNING so that the step can be rearmed on its build.- Parameters:
step- the running stepstrResult- the cause
-
isStepFollowed
Whether the build of a running step is followed by a task of this webapp. A running step that is not followed was interrupted by a restart or gave up on a lost connection : it has to be rearmed.- Parameters:
step- the step- Returns:
- true when followed
-
isVerifying
Whether a step is running a verification of its components.- Parameters:
step- the step- Returns:
- true when the step is running with a plan in VERIFY mode
-
rearmStep
Rearms a running step that nobody follows : its known Jenkins build is followed again until its result is recorded ; without a known build the step is failed, so that it can be prepared and launched again.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step number- Returns:
- true when something was done, false when the step is not running or is still followed
-
rearmRunningSteps
public static int rearmRunningSteps()Rearms every step left RUNNING by a previous run of the webapp, the step 0 of any campaign included.- Returns:
- the number of steps rearmed
-
completeStep
public static void completeStep(PlatformRelease campaign, PlatformReleaseStep step, PlatformStepResult result, String strJenkinsResult) throws IOException Records the success of a step and unlocks the next one. The components released by the failed attempts of the same step are kept in the stored result, so that the next steps know every version released.- Parameters:
campaign- the campaign, loaded with its stepsstep- the stepresult- the result reported by the pipelinestrJenkinsResult- the Jenkins build result- Throws:
IOException- if the result cannot be serialized
-
failStep
public static void failStep(PlatformRelease campaign, PlatformReleaseStep step, String strJenkinsResult) Records the failure of a step : the campaign stays on this step, which can be prepared and sent again.- Parameters:
campaign- the campaignstep- the stepstrJenkinsResult- the Jenkins build result
-
failStep
public static void failStep(PlatformRelease campaign, PlatformReleaseStep step, String strJenkinsResult, PlatformStepResult partialResult) Records the failure of a step with the partial report of the pipeline : the components released before the failure are stored, so that the next attempt of the step does not release them again.- Parameters:
campaign- the campaignstep- the stepstrJenkinsResult- the Jenkins build resultpartialResult- the components released before the failure, null when the report could not be read
-
getStepStamp
Identifies the state of a step as seen by a prepared screen : the screen must be rebuilt when the step was run meanwhile, otherwise components published by a failed attempt would be sent again.- Parameters:
step- the step, null when unknown- Returns:
- a stamp made of the status and the end date
-
isRunning
Whether a step of the campaign is being run : a Jenkins build is in progress and the campaign must not be removed.- Parameters:
campaign- the campaign, with its steps when loaded- Returns:
- true when running
-
canVerifyExport
Whether the CSV export may be marked as verified : only once step 4 succeeded and while step 5 has not been run.- Parameters:
campaign- the campaign, loaded with its steps- Returns:
- true when the verification is expected
-
getStepReleaseType
public static PlatformReleaseType getStepReleaseType(PlatformRelease campaign, PlatformStepCode code) Returns the release type of a step : stable for the stable-only steps, the campaign type otherwise.- Parameters:
campaign- the campaigncode- the step code- Returns:
- the release type
-
loadStepAggregate
public static Site loadStepAggregate(PlatformRelease campaign, int nStepNumber, ReleaserUser user, Locale locale) Loads the aggregate of a step in a transient site : clone, POM, components according to the step source, remote informations, target versions according to the release type, versions already released by the previous steps.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step numberuser- the releaser user (credentials)locale- the locale of the comments- Returns:
- the transient site
-
downgradeComponent
public static void downgradeComponent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId) Uses, instead of releasing it, the last release of a component of a step, and keeps the choice.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the stepstrArtifactId- the component artifactId
-
upgradeComponent
public static void upgradeComponent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId) Uses the newer release published in Nexus for a component of a step, and keeps the choice.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the stepstrArtifactId- the component artifactId
-
cancelUpgradeComponent
public static void cancelUpgradeComponent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId) Cancels the use of a newer release for a component of a step, and forgets the choice.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the stepstrArtifactId- the component artifactId
-
usePomVersion
public static void usePomVersion(PlatformRelease campaign, int nStepNumber, Site site, boolean bParent, String strChoice, Locale locale) Records the choice made for a version of the platform POM : "keep" to leave the POM as it is, a version to let the pipeline set it before the release, null to forget the choice. A version must be the one released by the campaign or a published release for the core of the campaign. The step is loaded again to apply the choice.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step numbersite- the transient site of the stepbParent- true for the parent POM version, false for the lutece-core versionstrChoice- "keep", a version, or nulllocale- the locale of the messages- Throws:
fr.paris.lutece.portal.service.util.AppException- when the version is not acceptable
-
loadParentVersions
Proposes, for the aggregate and every component of a step whose parent is a POM of the core line (lutece-global-pom, lutece-site-pom), the last version of that parent when it is newer than the declared one : the version released by the campaign at the step of that parent, otherwise the last release published in Nexus for the core version of the campaign. The upgrades chosen earlier are re-applied.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step numbersite- the transient site of the step
-
upgradeParent
public static void upgradeParent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId, boolean bUpgrade) Chooses, or gives up, the upgrade of the parent POM of a resource of a step to its last version. The choice is kept in the Datastore with the other choices of the campaign and applied by the pipeline before the release commit.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the stepstrArtifactId- the artifactId of the aggregate or of a componentbUpgrade- true to release with the last parent version, false to keep the declared one
-
upgradeAllParents
Chooses the upgrade of the parent POM of the aggregate and of every flagged component of a step whose parent has a newer version.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the step
-
checkReleasable
Turns into a blocking anomaly the cases where a component cannot be released by this campaign, whatever the user does : a theme, never released from here ; a SNAPSHOT of the aggregate POM ahead of the last one published in Nexus, which the pipeline could not release ; a default branch built for another core version than the campaign. The Nexus check comes first : the parent is read in the POM of the current SNAPSHOT, which only exists when Nexus has it. Such a component is taken out of the components to release.- Parameters:
component- the componentnCoreMajor- the core version of the campaignlocale- the locale of the messages- Returns:
- true when the component is not releasable and now carries the blocking anomaly
-
useLatestSnapshot
public static void useLatestSnapshot(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId, boolean bUse, ReleaserUser user, Locale locale) Releases a flagged component from the last SNAPSHOT published in Nexus instead of the older SNAPSHOT still referenced by the aggregate POM, or goes back to the POM version. The choice is kept in the Datastore with the flag of the component and re-applied when the step is loaded again.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the stepstrArtifactId- the component artifactIdbUse- true to release the last published SNAPSHOT, false to go back to the POM versionuser- the releaser user, for the branch checklocale- the locale of the messages
-
getLatestSnapshotCandidates
Returns the flagged components whose POM SNAPSHOT is behind the last one published in Nexus, offered the "release the last SNAPSHOT" choice.- Parameters:
site- the transient site of the step- Returns:
- the artifactIds
-
getLatestSnapshotComponents
public static List<String> getLatestSnapshotComponents(int nIdPlatformRelease, int nStepNumber, Site site) Returns the components of a step for which the "release the last published SNAPSHOT" choice is active.- Parameters:
nIdPlatformRelease- the campaign idnStepNumber- the step numbersite- the transient site of the step- Returns:
- the artifactIds
-
getStayedInPrereleaseComponents
public static Map<String,String> getStayedInPrereleaseComponents(PlatformRelease campaign, int nStepNumber, Site site) Returns the components of a step not to release that stayed in beta or RC, with the campaign that released their beta or RC when known.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the step- Returns:
- artifactId to "#id name" of the campaign, empty when unknown
-
releaseFromTag
public static void releaseFromTag(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId, ReleaserUser user, Locale locale) Flags a component that stayed in beta or RC as to be released in stable from its tag, found on its repository ("artifactId-version", otherwise "vversion").- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the stepstrArtifactId- the component artifactIduser- the releaser user, for the repository credentialslocale- the locale of the messages
-
getFromTagComponents
public static Map<String,String> getFromTagComponents(int nIdPlatformRelease, int nStepNumber, Site site) Returns the components of a step released in stable from the tag of the beta or RC they stayed in.- Parameters:
nIdPlatformRelease- the campaign idnStepNumber- the step numbersite- the transient site of the step- Returns:
- artifactId to tag
-
checkComponentBranch
public static void checkComponentBranch(Component component, int nCoreMajor, ReleaserUser user, Locale locale) Checks that the branch of a component to release carries what the plan expects, before anything is sent to the pipeline : the version of its POM must be the SNAPSHOT referenced by the aggregate, and a parent of the core line (lutece-global-pom, lutece-site-pom) must be of the core version of the campaign. An unreadable POM or a mismatch is a blocking anomaly. A component that is not to be released, or that is blocked, is not checked ; the tag of a component released from a tag is checked by checkFromTagBranch.- Parameters:
component- the componentnCoreMajor- the core version of the campaignuser- the releaser user, for the repository credentialslocale- the locale of the messages
-
getStepRepositoryType
Returns the repository type of the aggregate of a step, the credentials asked before the step can be prepared.- Parameters:
nStepNumber- the step number- Returns:
- the repository type, null for an unknown step or an unsupported repository
-
getNeededRepositoryTypes
Returns the repository types a step needs credentials for : the host of its aggregate, then the hosts of its components, in order.- Parameters:
site- the transient site of the step- Returns:
- the repository types
-
getCredentialProblems
public static Map<RepositoryType,PlatformReleaseService.CredentialProblem> getCredentialProblems(Site site, ReleaserUser user) Diagnoses the credentials of the user for the hosts of the components of a step : missing when none was given, refused when every component of the host had its branch listing rejected for authentication and none succeeded. Without valid credentials the branches cannot be listed, the POM of the branch cannot be checked and nothing can be released.- Parameters:
site- the transient site of the stepuser- the releaser user, null when not authenticated- Returns:
- the problem of each repository type in trouble, in the order of the components ; empty when the credentials are fine
-
toggleProjectComponent
public static void toggleProjectComponent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId, ReleaserUser user, Locale locale) Toggles the "to be released" flag of a component of a step, like a site component. A component already released by a previous step cannot be toggled. A component taken out of the release gets its current version back as target.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step numbersite- the transient site of the stepstrArtifactId- the component artifactIduser- the releaser user, for the branch check of a component to releaselocale- the locale of the messages
-
selectSnapshotComponents
public static int selectSnapshotComponents(PlatformRelease campaign, int nStepNumber, Site site, ReleaserUser user, Locale locale) Flags every component of a step that can be released as to be released : still in SNAPSHOT, not flagged yet, not released by a previous attempt, without blocking anomaly and without pending upgrade, the same rule as the "add" button of a component line.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the stepuser- the releaser user, for the branch check of the flagged componentslocale- the locale of the messages- Returns:
- the number of components flagged
-
deselectSnapshotComponents
Unflags every component flagged as to be released in a step and not released by a previous attempt, the reverse ofselectSnapshotComponents(PlatformRelease, int, Site, ReleaserUser, Locale).- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the step- Returns:
- the number of components unflagged
-
hasSelectableSnapshotComponents
public static boolean hasSelectableSnapshotComponents(PlatformRelease campaign, int nStepNumber, Site site) Tells whether a step still has components thatselectSnapshotComponents(PlatformRelease, int, Site, ReleaserUser, Locale)would flag.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the step- Returns:
- true if at least one component can still be flagged
-
applyReleaseType
Selects, among the next versions of a component to release, the one matching the release type.- Parameters:
component- the componentreleaseType- the release type
-
applyReleaseType
Selects, among the next versions of an aggregate, the one matching the release type.- Parameters:
site- the aggregatereleaseType- the release type
-
selectTargetVersion
public static String selectTargetVersion(List<String> listTargetVersions, String strDefaultVersion, PlatformReleaseType releaseType) Selects the version matching a release type in a list of candidate versions : the first RC for RC, the first beta for beta, the first plain version otherwise. Falls back on the default when the list has no such entry.- Parameters:
listTargetVersions- the candidate versions (seeVersion.getNextReleaseVersions(String, String))strDefaultVersion- the version to keep when no candidate matchesreleaseType- the release type- Returns:
- the selected version
-
cycleTargetVersion
public static void cycleTargetVersion(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId) Moves the target version of a component of a step to the next candidate of the release type of the step, unlike the site screen which goes through every candidate.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the stepstrArtifactId- the component artifactId
-
cycleTargetVersion
Moves the target version of the aggregate of a step to the next candidate of the release type of the step.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the step
-
cancelDowngradeComponent
public static void cancelDowngradeComponent(PlatformRelease campaign, int nStepNumber, Site site, String strArtifactId) Cancels the downgrade of a component of a step, its target being then chosen again for the release type of the step.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the transient site of the stepstrArtifactId- the component artifactId
-
buildPlan
public static PlatformReleasePlan buildPlan(PlatformRelease campaign, int nStepNumber, Site site, boolean bDryRun, Locale locale) Builds the plan of a step : the flagged components that must be released, with the same rule as a site release (Component.shouldBeReleased(): a component whose snapshot is not the last one available, a downgrade or a theme is not released), plus the components released from a tag, in release order, then the aggregate with the version updates to apply to its POM.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step numbersite- the transient site of the stepbDryRun- true to ask the pipeline for a simulationlocale- the locale of the messages- Returns:
- the plan
-
canVerify
Whether the components of a step can be verified : only the step pipeline has a verification mode, not the lutece-platform pipeline of the last step.- Parameters:
code- the code of the step- Returns:
- true for the steps 1 to 4
-
buildPlan
public static PlatformReleasePlan buildPlan(PlatformRelease campaign, int nStepNumber, Site site, PlatformStepMode mode, Locale locale) Builds the plan of a step for a release, a simulation or a verification, seebuildPlan(PlatformRelease, int, Site, boolean, Locale). Only the step pipeline verifies : a verification of the last step, run by the lutece-platform pipeline, is refused.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step numbersite- the transient site of the stepmode- the mode of the buildlocale- the locale of the messages- Returns:
- the plan
-
isAggregateFromTagAllowed
Tells whether the aggregate of a step may be released from a beta or RC tag : only the core, the other aggregates being stable only (global-pom, site-pom) or not released by their step (lutece-platform).- Parameters:
code- the step code, null for the step 0- Returns:
- true for the core step
-
getTestedCommit
public static String getTestedCommit(PlatformResourceVerification verification, String strTargetVersion) Returns the commit whose tests passed at the verification of a resource, so that the release does not run them again on the same commit.- Parameters:
verification- the verification of the resource, null when not verifiedstrTargetVersion- the version to release- Returns:
- the commit, null when the verification failed, was made for another version or did not run the tests
-
getDeployRepository
public static String getDeployRepository(RepositoryType repositoryType, String strPrivateRepositoryUrl) Returns the Nexus repository a resource is deployed to : the private one for GitLab, the one of the POM for the others.- Parameters:
repositoryType- the platform of the resourcestrPrivateRepositoryUrl- the URL of the private release repository- Returns:
- the repository as expected by -DaltReleaseDeploymentRepository, null for the repository of the POM or when the private one is not configured
-
sortComponents
Orders the components of a step for a sequential release : libraries, then the other artifacts, then plugins, then modules. The POM order is kept inside each group.- Parameters:
listComponents- the components- Returns:
- the ordered components
-
getMasterBranch
Returns the master branch to merge a released resource into : none for a beta or RC target version, whatever the type of the campaign (a stable component may be released in a beta campaign and a beta component in a stable one), the master counterpart of the release branch otherwise.- Parameters:
strBranchReleaseFrom- the release branchstrTargetVersion- the version released- Returns:
- the master branch, or null when no merge applies
-
isMergedIntoMaster
Whether a released version is merged into the master branch : only a stable version is, never a beta or RC one.- Parameters:
strTargetVersion- the version released- Returns:
- true for a stable version
-
getStepReport
Returns the report of the last build of a step, simulation included.- Parameters:
campaign- the campaign, loaded with its stepsnStepNumber- the step number- Returns:
- the report, null when the step has none
-
getStepVerifications
public static Map<String,PlatformResourceVerification> getStepVerifications(PlatformReleaseStep step) Returns the last verification of each resource of a step, "groupId:artifactId" to verification.- Parameters:
step- the step, may be null- Returns:
- the verifications, empty when the step was never verified
-
getVerificationDate
Returns the date of the last verification of a step.- Parameters:
step- the step, may be null- Returns:
- the date, null when the step was never verified
-
getVerificationStatuses
public static Map<String,String> getVerificationStatuses(PlatformReleaseStep step, Site site, Map<String, String> mapBranchHeads) Returns the verification status of each resource to release in a prepared step, "groupId:artifactId" to OK, TO_FIX, WARNING, NOT_VERIFIED or STALE : the components to release, then the aggregate.- Parameters:
step- the stepsite- the transient site of the stepmapBranchHeads- the current commit of the branch of the verified resources, see getBranchHeads ; a resource missing from it is not stale- Returns:
- the statuses
-
getBranchHeads
public static Map<String,String> getBranchHeads(PlatformReleaseStep step, Site site, ReleaserUser user) Reads the current commit of the branch of every resource verified OK or with a warning, in parallel and with the credentials of the user : a resource whose branch moved since its verification is stale. A resource whose branch cannot be read is left out.- Parameters:
step- the stepsite- the transient site of the stepuser- the releaser user- Returns:
- "groupId:artifactId" to the current commit of its branch
-
getResourcesToConfirm
Returns the resources a release would be launched with although they are not verified, to fix or stale : the warnings are accepted.- Parameters:
mapStatuses- the status of each resource- Returns:
- "groupId:artifactId" to its status, empty when every resource is verified
-
getUntestedDecisions
Returns the decisions of a step that still hold, "groupId:artifactId" to decision.- Parameters:
step- the step, may be null- Returns:
- the decisions
-
getUndecidedUntestedResources
public static List<String> getUndecidedUntestedResources(PlatformReleaseStep step, Map<String, String> mapStatuses) Returns the resources a release cannot be launched with : to fix for commits made after their last beta or RC, without a decision.- Parameters:
step- the stepmapStatuses- the status of each resource to release, see getVerificationStatuses- Returns:
- the "groupId:artifactId" of the resources, empty when none
-
setUntestedDecision
public static boolean setUntestedDecision(PlatformReleaseStep step, String strCoordinates, String strUserName, boolean bAccept, boolean bFromTag) throws IOException Records the decision to release a resource from the SNAPSHOT despite its untested commits, or from the beta or RC tag they follow, on the commit of its last verification, or cancels it.- Parameters:
step- the stepstrCoordinates- the "groupId:artifactId" of the resourcestrUserName- the user who takes the decisionbAccept- true to record the decision, false to cancel itbFromTag- true to release from the tag, false from the SNAPSHOT- Returns:
- false when the last verification of the resource found no untested commits, or no tag for a release from the tag ; for a cancel, false when there was no decision (a decision can always be cancelled, even once the resource is verified from its tag)
- Throws:
IOException- if the result cannot be serialized
-
restrictPlan
Restricts a verification plan to some resources : the components not listed are removed, the aggregate too when it is not listed.- Parameters:
plan- the plansetCoordinates- the "groupId:artifactId" of the resources to keep
-
getRawVerificationStatuses
Returns the status of each resource as last verified, "groupId:artifactId" to OK, TO_FIX or WARNING, without comparing to the current target versions : for the summary of the campaign page, where the steps are not prepared.- Parameters:
step- the step- Returns:
- the statuses
-
countVerificationStatuses
Counts the resources of each verification status.- Parameters:
mapStatuses- the status of each resource- Returns:
- OK, TO_FIX, WARNING and NOT_VERIFIED to their number of resources
-
exportCsv
Exports the plans of every step of a campaign, components then aggregate, one line per resource.- Parameters:
campaign- the campaign, loaded with its steps- Returns:
- the CSV content
-
getStepBranches
Returns the release branch of every aggregate for a core version, as deduced by the campaign (shown when a campaign is created).- Parameters:
nCoreMajor- the core major version- Returns:
- the branch by step code, in step order
-
getPipelineParameters
Returns the pipeline parameters chosen on the screen of a step, by Jenkins parameter name (only the ones set).- Parameters:
nIdPlatformRelease- the campaign idnStepNumber- the step number- Returns:
- the parameters
-
savePipelineParameters
public static void savePipelineParameters(int nIdPlatformRelease, int nStepNumber, Map<String, String> mapParameters) Saves the pipeline parameters chosen on the screen of a step ; a null value removes the parameter.- Parameters:
nIdPlatformRelease- the campaign idnStepNumber- the step numbermapParameters- the parameters, by Jenkins parameter name
-
isValidReleaseTarget
Tells whether a release target sent for the lutece-platform pipeline is one the screen offers : all, or a module of the aggregate.- Parameters:
strReleaseTarget- the release target, may be nullsite- the prepared aggregate, may be null- Returns:
- true when the target is known
-
getEffectivePipelineParameters
public static Map<String,String> getEffectivePipelineParameters(PlatformRelease campaign, int nStepNumber, Site site) Returns the pipeline parameters shown on the screen of a step :the chosen ones (target, SNAPSHOT tolerance), completed with the values computed from the campaign and the prepared aggregate (core, next snapshot), shown for information only.- Parameters:
campaign- the campaignnStepNumber- the step numbersite- the prepared aggregate- Returns:
- the parameters, by Jenkins parameter name
-
applyPipelineParameters
public static void applyPipelineParameters(PlatformRelease campaign, int nStepNumber, PlatformReleasePlan plan) Copies the pipeline parameters chosen on the screen into the plan of a step before it is sent.- Parameters:
campaign- the campaignnStepNumber- the step numberplan- the plan
-
getStepBranchOverride
Returns the branch chosen on the screen of a step for its aggregate, in place of the one deduced from the core.- Parameters:
nIdPlatformRelease- the campaign idnStepNumber- the step number- Returns:
- the branch, null when the deduced one applies
-
saveStepBranch
Saves the branch chosen on the screen of a step for its aggregate ; null restores the branch deduced from the core.- Parameters:
nIdPlatformRelease- the campaign idnStepNumber- the step numberstrBranch- the branch
-