Class PlatformReleaseService

java.lang.Object
fr.paris.lutece.plugins.releaser.service.platform.PlatformReleaseService

public final class PlatformReleaseService extends Object
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.
  • Field Details

    • VERIFICATION_NOT_VERIFIED

      public static final String VERIFICATION_NOT_VERIFIED
      Verification status of a resource never verified, or verified for another version than its current target.
      See Also:
    • VERIFICATION_STALE

      public static final String 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 name
      releaseType - 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

      public static PlatformReleaseStep getStep(PlatformRelease campaign, int nStepNumber)
      Returns a step of a campaign, the step 0 included.
      Parameters:
      campaign - the campaign, loaded with its steps
      nStepNumber - the step number
      Returns:
      the step, or null if not found
    • canPrepareStep

      public static boolean canPrepareStep(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.
      Parameters:
      campaign - the campaign, loaded with its steps
      nStepNumber - the step number
      Returns:
      true if the step can be prepared
    • getStepLockReason

      public static String getStepLockReason(PlatformRelease campaign, int nStepNumber, boolean bSkip)
      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 steps
      nStepNumber - the step number
      bSkip - true when the step is to be skipped
      Returns:
      the message key, null when the step can be prepared or skipped
    • canSkipStep

      public static boolean canSkipStep(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.
      Parameters:
      campaign - the campaign, loaded with its steps
      nStepNumber - the step number
      Returns:
      true if the step can be skipped
    • skipStep

      public static void skipStep(PlatformRelease campaign, int nStepNumber)
      Skips a step and unlocks the next one.
      Parameters:
      campaign - the campaign, loaded with its steps
      nStepNumber - 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 steps
      nStepNumber - the step number
      plan - the plan to send
      user - the releaser user, whose credentials are sent to the pipeline : it clones and pushes with them
      locale - 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 sent
      user - the releaser user, for the repository credentials
      locale - the locale of the message
      Returns:
      the message refusing the launch, null when every master branch exists
    • checkLaunchPermissions

      public static String checkLaunchPermissions(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. 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 step
      user - 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 campaign
      step - the step
      plan - the plan sent
      Throws:
      IOException - if the plan cannot be serialized
    • attachBuild

      public static void attachBuild(PlatformReleaseStep step, String strBuildUrl, int nBuildNumber)
      Records the Jenkins build of a running step, once the queue has started it.
      Parameters:
      step - the step
      strBuildUrl - the Jenkins build URL
      nBuildNumber - 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 campaign
      step - the step
      strJenkinsResult - the Jenkins build result
      strReport - 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 IOException
      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. 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 steps
      step - the step
      strJenkinsResult - the Jenkins result of the verification build
      strReport - the text report of the build, null when unreadable
      mapVerifications - 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 stored
      plan - the plan sent with the build
      result - the result of this build, null when none could be read
    • recordFollowUpGivenUp

      public static void recordFollowUpGivenUp(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.
      Parameters:
      step - the running step
      strResult - the cause
    • isStepFollowed

      public static boolean isStepFollowed(PlatformReleaseStep step)
      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

      public static boolean isVerifying(PlatformReleaseStep step)
      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

      public static boolean rearmStep(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.
      Parameters:
      campaign - the campaign, loaded with its steps
      nStepNumber - 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 steps
      step - the step
      result - the result reported by the pipeline
      strJenkinsResult - 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 campaign
      step - the step
      strJenkinsResult - 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 campaign
      step - the step
      strJenkinsResult - the Jenkins build result
      partialResult - the components released before the failure, null when the report could not be read
    • getStepStamp

      public static String getStepStamp(PlatformReleaseStep step)
      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

      public static boolean isRunning(PlatformRelease campaign)
      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

      public static boolean canVerifyExport(PlatformRelease campaign)
      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 campaign
      code - 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 steps
      nStepNumber - the step number
      user - 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 campaign
      nStepNumber - the step number
      site - the transient site of the step
      strArtifactId - 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 campaign
      nStepNumber - the step number
      site - the transient site of the step
      strArtifactId - 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 campaign
      nStepNumber - the step number
      site - the transient site of the step
      strArtifactId - 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 steps
      nStepNumber - the step number
      site - the transient site of the step
      bParent - true for the parent POM version, false for the lutece-core version
      strChoice - "keep", a version, or null
      locale - the locale of the messages
      Throws:
      fr.paris.lutece.portal.service.util.AppException - when the version is not acceptable
    • loadParentVersions

      public static void loadParentVersions(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. The upgrades chosen earlier are re-applied.
      Parameters:
      campaign - the campaign, loaded with its steps
      nStepNumber - the step number
      site - 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 campaign
      nStepNumber - the step number
      site - the transient site of the step
      strArtifactId - the artifactId of the aggregate or of a component
      bUpgrade - true to release with the last parent version, false to keep the declared one
    • upgradeAllParents

      public static void upgradeAllParents(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.
      Parameters:
      campaign - the campaign
      nStepNumber - the step number
      site - the transient site of the step
    • checkReleasable

      public static boolean checkReleasable(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. 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 component
      nCoreMajor - the core version of the campaign
      locale - 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 campaign
      nStepNumber - the step number
      site - the transient site of the step
      strArtifactId - the component artifactId
      bUse - true to release the last published SNAPSHOT, false to go back to the POM version
      user - the releaser user, for the branch check
      locale - the locale of the messages
    • getLatestSnapshotCandidates

      public static List<String> getLatestSnapshotCandidates(Site site)
      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 id
      nStepNumber - the step number
      site - 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 campaign
      nStepNumber - the step number
      site - 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 campaign
      nStepNumber - the step number
      site - the transient site of the step
      strArtifactId - the component artifactId
      user - the releaser user, for the repository credentials
      locale - 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 id
      nStepNumber - the step number
      site - 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 component
      nCoreMajor - the core version of the campaign
      user - the releaser user, for the repository credentials
      locale - the locale of the messages
    • getStepRepositoryType

      public static RepositoryType getStepRepositoryType(int nStepNumber)
      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

      public 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.
      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 step
      user - 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 steps
      nStepNumber - the step number
      site - the transient site of the step
      strArtifactId - the component artifactId
      user - the releaser user, for the branch check of a component to release
      locale - 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 campaign
      nStepNumber - the step number
      site - the transient site of the step
      user - the releaser user, for the branch check of the flagged components
      locale - the locale of the messages
      Returns:
      the number of components flagged
    • deselectSnapshotComponents

      public static int deselectSnapshotComponents(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 of selectSnapshotComponents(PlatformRelease, int, Site, ReleaserUser, Locale).
      Parameters:
      campaign - the campaign
      nStepNumber - the step number
      site - 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 that selectSnapshotComponents(PlatformRelease, int, Site, ReleaserUser, Locale) would flag.
      Parameters:
      campaign - the campaign
      nStepNumber - the step number
      site - the transient site of the step
      Returns:
      true if at least one component can still be flagged
    • applyReleaseType

      public static void applyReleaseType(Component component, PlatformReleaseType releaseType)
      Selects, among the next versions of a component to release, the one matching the release type.
      Parameters:
      component - the component
      releaseType - the release type
    • applyReleaseType

      public static void applyReleaseType(Site site, PlatformReleaseType releaseType)
      Selects, among the next versions of an aggregate, the one matching the release type.
      Parameters:
      site - the aggregate
      releaseType - 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 (see Version.getNextReleaseVersions(String, String))
      strDefaultVersion - the version to keep when no candidate matches
      releaseType - 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 campaign
      nStepNumber - the step number
      site - the transient site of the step
      strArtifactId - the component artifactId
    • cycleTargetVersion

      public static void cycleTargetVersion(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.
      Parameters:
      campaign - the campaign
      nStepNumber - the step number
      site - 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 campaign
      nStepNumber - the step number
      site - the transient site of the step
      strArtifactId - 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 steps
      nStepNumber - the step number
      site - the transient site of the step
      bDryRun - true to ask the pipeline for a simulation
      locale - the locale of the messages
      Returns:
      the plan
    • canVerify

      public static boolean canVerify(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.
      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, see buildPlan(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 steps
      nStepNumber - the step number
      site - the transient site of the step
      mode - the mode of the build
      locale - the locale of the messages
      Returns:
      the plan
    • isAggregateFromTagAllowed

      public static boolean isAggregateFromTagAllowed(PlatformStepCode code)
      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 verified
      strTargetVersion - 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 resource
      strPrivateRepositoryUrl - 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

      public static List<Component> sortComponents(List<Component> listComponents)
      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

      public static String getMasterBranch(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.
      Parameters:
      strBranchReleaseFrom - the release branch
      strTargetVersion - the version released
      Returns:
      the master branch, or null when no merge applies
    • isMergedIntoMaster

      public static boolean isMergedIntoMaster(String strTargetVersion)
      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

      public static String getStepReport(PlatformRelease campaign, int nStepNumber)
      Returns the report of the last build of a step, simulation included.
      Parameters:
      campaign - the campaign, loaded with its steps
      nStepNumber - 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

      public static String getVerificationDate(PlatformReleaseStep step)
      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 step
      site - the transient site of the step
      mapBranchHeads - 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 step
      site - the transient site of the step
      user - the releaser user
      Returns:
      "groupId:artifactId" to the current commit of its branch
    • getResourcesToConfirm

      public static Map<String,String> 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.
      Parameters:
      mapStatuses - the status of each resource
      Returns:
      "groupId:artifactId" to its status, empty when every resource is verified
    • getUntestedDecisions

      public static Map<String,PlatformUntestedDecision> getUntestedDecisions(PlatformReleaseStep step)
      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 step
      mapStatuses - 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 step
      strCoordinates - the "groupId:artifactId" of the resource
      strUserName - the user who takes the decision
      bAccept - true to record the decision, false to cancel it
      bFromTag - 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

      public static void restrictPlan(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.
      Parameters:
      plan - the plan
      setCoordinates - the "groupId:artifactId" of the resources to keep
    • getRawVerificationStatuses

      public static Map<String,String> getRawVerificationStatuses(PlatformReleaseStep step)
      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

      public static Map<String,Integer> countVerificationStatuses(Map<String,String> mapStatuses)
      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

      public static String exportCsv(PlatformRelease campaign)
      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

      public 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).
      Parameters:
      nCoreMajor - the core major version
      Returns:
      the branch by step code, in step order
    • getPipelineParameters

      public static Map<String,String> getPipelineParameters(int nIdPlatformRelease, int nStepNumber)
      Returns the pipeline parameters chosen on the screen of a step, by Jenkins parameter name (only the ones set).
      Parameters:
      nIdPlatformRelease - the campaign id
      nStepNumber - 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 id
      nStepNumber - the step number
      mapParameters - the parameters, by Jenkins parameter name
    • isValidReleaseTarget

      public static boolean isValidReleaseTarget(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.
      Parameters:
      strReleaseTarget - the release target, may be null
      site - 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 campaign
      nStepNumber - the step number
      site - 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 campaign
      nStepNumber - the step number
      plan - the plan
    • getStepBranchOverride

      public static String getStepBranchOverride(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.
      Parameters:
      nIdPlatformRelease - the campaign id
      nStepNumber - the step number
      Returns:
      the branch, null when the deduced one applies
    • saveStepBranch

      public static void saveStepBranch(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.
      Parameters:
      nIdPlatformRelease - the campaign id
      nStepNumber - the step number
      strBranch - the branch