forked from e-gineering/gitflow-helper-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPromoteMasterMojo.java
61 lines (53 loc) · 2.63 KB
/
PromoteMasterMojo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.e_gineering.maven.gitflowhelper;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import java.util.List;
/**
* If the build is being executed from a DEVELOPMENT, HOTFIX or RELEASE branch, attach an artifact containing a list of
* the attached artifacts. This list is then used for promoting artifacts from the stage repository to the release
* repository. Or it can be used manually by the attach-deployed goal.
*
* If the build is being executed from the MASTER or SUPPORT branch, the artifacts from the stage repository
* are downloaded and attached to the current build as if they were generated by the 'package' phase and checked by the
* 'verify' phase (which should have happened as part of the build deploying to 'stage')
*/
@Mojo(name = "promote-master", defaultPhase = LifecyclePhase.INSTALL)
public class PromoteMasterMojo extends AbstractGitflowBasedRepositoryMojo {
/**
* List of groupId:artifactId strings that refer to plugins that should be retained while building on master.
*
* Note that this property is listed here for documentation purposes, but it is handled within
* {@link MasterPromoteExtension}.
*/
@Parameter(property = "retainPlugins")
private List<String> retainPlugins;
@Override
protected void execute(final GitBranchInfo gitBranchInfo) throws MojoExecutionException, MojoFailureException {
switch (gitBranchInfo.getType()) {
case DEVELOPMENT:
case HOTFIX:
case RELEASE: {
// In order to use promote-master or attach-deployed, we need to build an artifactCatalog on deployable branches.
attachArtifactCatalog();
break;
}
// In order to use attach-deployed, we need to build the artifactCatalog.
case OTHER: {
String otherBranchesToDeploy = resolveExpression(otherDeployBranchPattern);
if (!"".equals(otherBranchesToDeploy) && gitBranchInfo.getName().matches(otherBranchesToDeploy)) {
attachArtifactCatalog();
}
break;
}
case SUPPORT:
case MASTER: {
getLog().info("Resolving & Reattaching existing artifacts from stageDeploymentRepository [" + stageDeploymentRepository + "]");
attachExistingArtifacts(stageDeploymentRepository, true);
break;
}
}
}
}