Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class AddVersionAction extends BaseAction implements RunAction2 {

@Nullable
private String versionName;
@Nullable
private String fromVersion;

private boolean failureIgnored = false;
private long timeout = Constants.DEFAULT_HTTP_TIMEOUT;
@Nullable
Expand Down Expand Up @@ -106,6 +109,15 @@ public void setVersionName(@Nullable String versionName) {
this.versionName = versionName;
}

@Nullable
public String getFromVersion() {
return fromVersion;
}

public void setFromVersion(@Nullable String fromVersion) {
this.fromVersion = fromVersion;
}

public boolean isFailureIgnored() {
return failureIgnored;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public class AddVersionBuilder extends BaseActionBuilder implements SimpleBuildS

@Nullable
private String versionName = "";
@Nullable
private String fromVersion = "";
private long timeout = Constants.DEFAULT_HTTP_TIMEOUT;
private boolean failureIgnored = false;
@Nullable
Expand Down Expand Up @@ -188,6 +190,16 @@ public void setVersionName(@Nullable String versionName) {
this.versionName = versionName;
}

@Nullable
public String getFromVersion() {
return fromVersion;
}

@DataBoundSetter
public void setFromVersion(@Nullable String fromVersion) {
this.fromVersion = fromVersion;
}

public boolean isFailureIgnored() {
return failureIgnored;
}
Expand Down Expand Up @@ -510,6 +522,9 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnul
if (isBlueprint()) {
requestBuilder.objectives(VersionObjective.BLUEPRINT);
}
if (cloneVersion && StringUtils.isNotEmpty(fromVersion)) {
requestBuilder.fromVersionGuid(applicationService.getApplicationVersionGuidFromName(applicationGuid, vars.expand(fromVersion)));
}
if (StringUtils.isNotBlank(resolvedSnapshotName)) {
requestBuilder.snapshotName(resolvedSnapshotName);
}
Expand All @@ -525,7 +540,7 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnul
log.println(AddVersionBuilder_AddVersion_success_analysisComplete());
run.setResult(Result.SUCCESS);
}
} catch (JobServiceException e) {
} catch (JobServiceException | ApplicationServiceException e) {
// Should we check if the original cause is an InterruptedException and attempt to cancel the job ?
if (e.getCause() != null && e.getCause() instanceof InterruptedException) {
if (jobGuid != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class DeliverAction extends BaseAction implements RunAction2 {
private boolean cloneVersion = false;
@Nullable
private String versionName;
@Nullable
private String fromVersion;

private boolean failureIgnored = false;
private long timeout = Constants.DEFAULT_HTTP_TIMEOUT;
@Nullable
Expand Down Expand Up @@ -113,6 +116,15 @@ public void setVersionName(@Nullable String versionName) {
this.versionName = versionName;
}

@Nullable
public String getFromVersion() {
return fromVersion;
}

public void setFromVersion(@Nullable String fromVersion) {
this.fromVersion = fromVersion;
}

public boolean isFailureIgnored() {
return failureIgnored;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public class DeliverBuilder extends BaseActionBuilder implements SimpleBuildStep
private boolean cloneVersion = false;
@Nullable
private String versionName = "";
@Nullable
private String fromVersion = "";
private long timeout = Constants.DEFAULT_HTTP_TIMEOUT;
private boolean failureIgnored = false;
@Nullable
Expand Down Expand Up @@ -230,6 +232,16 @@ public void setVersionName(@Nullable String versionName) {
this.versionName = versionName;
}

@Nullable
public String getFromVersion() {
return fromVersion;
}

@DataBoundSetter
public void setFromVersion(@Nullable String fromVersion) {
this.fromVersion = fromVersion;
}

public boolean isFailureIgnored() {
return failureIgnored;
}
Expand Down Expand Up @@ -532,11 +544,13 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnul
if (inplaceMode || isSetAsCurrent()) {
requestBuilder.endStep(Constants.SET_CURRENT_STEP_NAME);
}

if (isBlueprint()) {
requestBuilder.objectives(VersionObjective.BLUEPRINT);
}

if (cloneVersion && StringUtils.isNotEmpty(fromVersion)) {
requestBuilder.fromVersionGuid(applicationService.getApplicationVersionGuidFromName(applicationGuid, vars.expand(fromVersion)));
}
log.println("Exclusion patterns : " + exclusionPatterns);
requestBuilder.deliveryConfigGuid(applicationService.createDeliveryConfiguration(applicationGuid, fileName, exclusionPatterns, applicationHasVersion));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<f:entry title="${%cloneVersion}" field="cloneVersion" description="${%cloneVersion.descr}">
<f:checkbox field="cloneVersion" value="${cloneVersion}" default="true"/>
</f:entry>
<f:entry title="${%fromVersion}" field="fromVersion" description="${%fromVersion.descr}">
<f:textbox/>
</f:entry>
<f:entry title="${%blueprint}" field="blueprint" description="${%blueprint.descr}">
<f:checkbox field="blueprint" value="${blueprint}" default="false"/>
</f:entry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ domainName=Domain Name
domainName.descr=Name of the domain to assign to this application. Will be created if it doesn't exists in AIP Console. If no specified, no domain will be assigned or created.
processImaging=Publish to Imaging
processImaging.descr=Publish analysis data to Imaging if an Imaging instance is defined in AIP Console

blueprint=Blueprint objective
blueprint.descr=Add blueprint objective to the objectives list

fromVersion=Version to copy from
fromVersion.descr=The cloned version will be copied from this version.
aipConsoleUrl=AIP Console URL if different than the global configuration
aipConsoleUrl.descr=The root URL to access AIP Console
apiKey=API Key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ aipConsoleUrl=URL de AIP Console si différente de la configuration globale
aipConsoleUrl.descr=L''URL d''accès à AIP Console
apiKey=Clé d'API
apiKey.descr=La clé d'API permettant l''accès à AIP Console
fromVersion=Version à partir de laquelle copier
fromVersion.descr=La version clonée sera copiée à partir de cette version .
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<f:entry title="${%cloneVersion}" field="cloneVersion" description="${%cloneVersion.descr}">
<f:checkbox field="cloneVersion" value="${cloneVersion}" default="true"/>
</f:entry>
<f:entry title="${%fromVersion}" field="fromVersion" description="${%fromVersion.descr}">
<f:textbox/>
</f:entry>
<f:entry title="${%blueprint}" field="blueprint" description="${%blueprint.descr}">
<f:checkbox field="blueprint" value="${blueprint}" default="false"/>
</f:entry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ aipConsoleUrl=AIP Console URL if different than the global configuration
aipConsoleUrl.descr=The root URL to access AIP Console
apiKey=API Key
apiKey.descr=The API Key to access AIP Console
fromVersion=Version to copy from
fromVersion.descr=The cloned version will be copied from this version.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
setAsCurrent=Utiliser cette version pour l'analyse
setAsCurrent.descr=La version ajout�e sera d�finie comme la version d'analyse
setAsCurrent.descr=La version ajout�e sera d�finie comme la version d'analyse
aipConsoleUrl=URL d''AIP Console
aipConsoleUrl.descr=L''URL d''accès à AIP Console
apiKey=Clé d'API
apiKey.descr=La clé d'API permettant l''accès à AIP Console
fromVersion=Version à partir de laquelle copier
fromVersion.descr=La version clonée sera copiée à partir de cette version .

Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public void testAddVersionStepToJob() throws Exception {
project = jenkins.configRoundtrip(project);
AddVersionBuilder job = new AddVersionBuilder(TEST_APP_NAME, TEST_ARCHIVE_NAME);
job.setDomainName("");
job.setFromVersion("");
jenkins.assertEqualDataBoundBeans(job, project.getBuildersList().get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.castsoftware.aip.console.tools.core.exceptions.UploadException;
import com.castsoftware.aip.console.tools.core.services.ApplicationService;
import com.castsoftware.aip.console.tools.core.services.DebugOptionsService;
import com.castsoftware.aip.console.tools.core.services.DebugOptionsServiceImpl;
import com.castsoftware.aip.console.tools.core.services.JobsService;
import com.castsoftware.aip.console.tools.core.services.RestApiService;
import com.castsoftware.aip.console.tools.core.services.UploadService;
Expand Down Expand Up @@ -85,6 +84,10 @@ public AddVersionCommand(RestApiService restApiService, JobsService jobsService,
@CommandLine.Option(names = {"-v", "--version-name"}, paramLabel = "VERSION_NAME", description = "The name of the version to create")
private String versionName;

@CommandLine.Option(names = {"-from-v", "--from-version-name"}, paramLabel = "FROM_VERSION_NAME", description = "The name of the version to copy from when clone or rescan is operating.",
required = false)
private String fromVersionName;

@CommandLine.Option(names = "--snapshot-name", paramLabel = "SNAPSHOT_NAME", description = "The name of the snapshot to generate")
private String snapshotName;
/**
Expand Down Expand Up @@ -212,7 +215,6 @@ public Integer call() {

// check that the application actually has versions, otherwise it's just an add version job
boolean cloneVersion = (app.isInPlaceMode() || !disableClone) && applicationService.applicationHasVersion(applicationGuid);

JobRequestBuilder builder = JobRequestBuilder.newInstance(applicationGuid, sourcePath, cloneVersion ? JobType.CLONE_VERSION : JobType.ADD_VERSION)
.versionName(versionName)
.releaseAndSnapshotDate(new Date())
Expand All @@ -227,7 +229,11 @@ public Integer call() {
if (blueprint) {
builder.objectives(VersionObjective.BLUEPRINT);
}

if (cloneVersion && StringUtils.isNotEmpty(fromVersionName)) {
String fromVersionGuid = applicationService.getApplicationVersionGuidFromName(applicationGuid, fromVersionName);
log.info("Clone version {} copied from {} with GUID {}", versionName, fromVersionName, fromVersionGuid);
builder.fromVersionGuid(fromVersionGuid);
}
if (StringUtils.isNotBlank(snapshotName)) {
builder.snapshotName(snapshotName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public class DeliverVersionCommand implements Callable<Integer> {
description = "The name of the version to create")
private String versionName;

@CommandLine.Option(names = {"-from-v", "--from-version-name"},
paramLabel = "FROM_VERSION_NAME",
description = "The name of the version to copy from when clone or rescan is operating.",
required = false)
private String fromVersionName;

// Hiding this, to avoid breaking commands already using it
// Analyze command will automatically set as current when starting so it's unnecessary
@CommandLine.Option(names = {"-d", "--auto-deploy"},
Expand Down Expand Up @@ -216,6 +222,11 @@ public Integer call() throws Exception {
if (blueprint) {
builder.objectives(VersionObjective.BLUEPRINT);
}
if (cloneVersion && StringUtils.isNotEmpty(fromVersionName)) {
String fromVersionGuid = applicationService.getApplicationVersionGuidFromName(applicationGuid, fromVersionName);
log.info("Clone version {} copied from {} with GUID {}", versionName, fromVersionName, fromVersionGuid);
builder.fromVersionGuid(fromVersionGuid);
}

String deliveryConfigGuid = applicationService.createDeliveryConfiguration(applicationGuid, sourcePath, exclusionPatterns, cloneVersion);
log.info("delivery configuration guid " + deliveryConfigGuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class JobRequestBuilder {
private JobType jobType;
private String nodeGuid;
private String versionName;
private String fromVersionGuid;
private String versionGuid;
private String startStep;
private String endStep;
Expand Down Expand Up @@ -68,6 +69,13 @@ public JobRequestBuilder versionName(String versionName) {
return this;
}

public JobRequestBuilder fromVersionGuid(String fromVersionGuid) {
if (StringUtils.isNotBlank(fromVersionGuid)) {
this.fromVersionGuid = fromVersionGuid;
}
return this;
}

public JobRequestBuilder startStep(String startStep) {
this.startStep = startStep;
return this;
Expand Down Expand Up @@ -177,6 +185,9 @@ private Map<String, String> getJobParameters() {
if (StringUtils.isNotBlank(versionGuid)) {
parameters.put(Constants.PARAM_VERSION_GUID, versionGuid);
}
if (StringUtils.isNotBlank(fromVersionGuid)) {
parameters.put(Constants.PARAM_FROM_VERSION_GUID, fromVersionGuid);
}
parameters.put(Constants.PARAM_START_STEP, startStep);
parameters.put(Constants.PARAM_END_STEP, endStep);
parameters.put(Constants.PARAM_IGNORE_CHECK, Boolean.toString(ignoreCheck));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public interface ApplicationService {
*/
boolean applicationHasVersion(String applicationGuid) throws ApplicationServiceException;

/**
* @param applicationGuid host application GUID
* @param fromVersionName the version nae that Guid should be retrieved.
* @return the version GUID is exists otherwise null
* @throws ApplicationServiceException
*/
String getApplicationVersionGuidFromName(String applicationGuid, String fromVersionName) throws ApplicationServiceException;

/**
* Retrieve an application's GUID from the given application name.
* <p/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ApplicationServiceImpl implements ApplicationService {

public ApplicationServiceImpl(RestApiService restApiService, JobsService jobsService) {
this.restApiService = restApiService;
this.jobService = jobsService;
jobService = jobsService;
}

@Override
Expand Down Expand Up @@ -86,6 +86,13 @@ public boolean applicationHasVersion(String applicationGuid) throws ApplicationS
!appVersions.isEmpty();
}

@Override
public String getApplicationVersionGuidFromName(String applicationGuid, String fromVersionName) throws ApplicationServiceException {
Set<VersionDto> appVersions = getApplicationVersion(applicationGuid);
Optional<VersionDto> versionDto = appVersions.stream().filter(v -> v.getName().equalsIgnoreCase(fromVersionName)).findFirst();
return versionDto.isPresent() ? versionDto.get().getGuid() : null;
}

@Override
public String getOrCreateApplicationFromName(String applicationName, boolean autoCreate) throws ApplicationServiceException {
return getOrCreateApplicationFromName(applicationName, autoCreate, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private Constants() {
public static final String PARAM_BACKUP_ENABLED = "backupApplication";
public static final String PARAM_BACKUP_NAME = "backupName";
public static final String PARAM_VERSION_GUID = "versionGuid";
public static final String PARAM_FROM_VERSION_GUID = "fromVersionGuid";
public static final String PARAM_SNAPSHOT_NAME = "snapshotName";
public static final String PARAM_DELIVERY_CONFIG_GUID = "deliveryConfigGuid";
public static final String PARAM_ENABLE_AUTO_DISCOVER = "extensionAutoConfigEnabled";
Expand Down