Skip to content

Commit b932968

Browse files
DAT-16380 (#20)
* Fix docs. * Implement specific workflowId for downloading artifacts Added a parameter for workflowId in the downloadArtifact method. Previously, the method was using the global workflowId for both the main workflow and the Pro workflow, which would cause issues if these workflows had different IDs. Now, the Pro workflow uses its own specific workflowId to download artifacts, ensuring the correct artifact is downloaded for each respective workflow.
1 parent d4c7d9a commit b932968

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ By default, it expects it to be an upgrade, unless `allowInstall` / `liquibase.s
3939
The branch to use is set via the liquibase.sdk.branchSearch setting. To install a branch from a fork, reference it as `owner:branch-name`
4040

4141
Examples:
42-
- `mvn org.liquibase.ext:liquibase-sdk-maven-plugin:0.9:install-cli "-Dliquibase.sdk.branchSearch=local-branch,master"` to install the code from `liquibase/liquibase:local-branch` and if that branch doesn't exist fall back to `master`
43-
- `mvn org.liquibase.ext:liquibase-sdk-maven-plugin:0.9:install-cli "-Dliquibase.sdk.branchSearch=fork-owner:their-branch"` to install the code from `fork-owner/liquibase:their-branch`
42+
- `mvn org.liquibase.ext:liquibase-sdk-maven-plugin:0.9:install-snapshot-cli "-Dliquibase.sdk.branchSearch=local-branch,master"` to install the code from `liquibase/liquibase:local-branch` and if that branch doesn't exist fall back to `master`
43+
- `mvn org.liquibase.ext:liquibase-sdk-maven-plugin:0.9:install-snapshot-cli "-Dliquibase.sdk.branchSearch=fork-owner:their-branch"` to install the code from `fork-owner/liquibase:their-branch`
4444

4545
All available arguments:
4646

src/main/java/liquibase/sdk/maven/plugins/InstallSnapshotCliMojo.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public class InstallSnapshotCliMojo extends AbstractGitHubMojo {
3535
@Parameter(property = "liquibase.sdk.workflowId")
3636
protected String workflowId;
3737

38+
@Parameter(property = "liquibase.sdk.proWorkflowId")
39+
protected String proWorkflowId;
40+
3841
public void execute() throws MojoExecutionException, MojoFailureException {
3942
File liquibaseHomeDir = new File(liquibaseHome);
4043
if (liquibaseHomeDir.exists()) {
@@ -70,7 +73,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7073
//replace everything in the CLI except liquibase-commercial.jar
7174
String headBranchFilename = matchingLabel.replaceFirst(".*:", "").replaceAll("[^a-zA-Z0-9\\-_.]", "_");
7275

73-
File file = downloadArtifact(github, repo, matchingLabel, "liquibase-zip-" + headBranchFilename);
76+
File file = downloadArtifact(github, repo, matchingLabel, "liquibase-zip-" + headBranchFilename, workflowId);
7477

7578
ArchiveUtil.unzipCli(file, liquibaseHomeDir, log, path -> {
7679
if (path.getName().equals("internal/lib/liquibase-commercial.jar")) {
@@ -81,7 +84,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
8184
} else {
8285
//upgrading an extension
8386
if (repo.equals("liquibase/liquibase-pro")) {
84-
File file = downloadArtifact(github, repo, matchingLabel, "liquibase-commercial-modules");
87+
File file = downloadArtifact(github, repo, matchingLabel, "liquibase-commercial-modules", proWorkflowId);
8588
ArchiveUtil.unzipCli(file, liquibaseHomeDir, log,
8689
path -> path.getName().endsWith("liquibase-commercial-0-SNAPSHOT.jar"),
8790
path -> {
@@ -103,8 +106,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
103106
}
104107
}
105108

106-
private File downloadArtifact(GitHubClient github, String repo, String matchingLabel, String artifactName) throws IOException, MojoFailureException {
107-
File file = github.downloadArtifact(repo, matchingLabel, artifactName, GitHubClient.getWorkflowId(repo, workflowId), skipFailedBuilds);
109+
private File downloadArtifact(GitHubClient github, String repo, String matchingLabel, String artifactName, String currentWorkflowId) throws IOException, MojoFailureException {
110+
File file = github.downloadArtifact(repo, matchingLabel, artifactName, GitHubClient.getWorkflowId(repo, currentWorkflowId), skipFailedBuilds);
108111

109112
if (file == null) {
110113
throw new MojoFailureException("Cannot find " + artifactName + ".zip");

0 commit comments

Comments
 (0)