-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from ovcharenko-di/feature/save-dt
Сохранение ИБ в виде артефакта после выполнения всех шагов инциализации
- Loading branch information
Showing
16 changed files
with
223 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/ru/pulsar/jenkins/library/configuration/ArchiveInfobaseOptions.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ru.pulsar.jenkins.library.configuration | ||
|
||
import com.cloudbees.groovy.cps.NonCPS | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties | ||
import com.fasterxml.jackson.annotation.JsonPropertyDescription | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
class ArchiveInfobaseOptions implements Serializable { | ||
|
||
@JsonPropertyDescription("Сохранять всегда") | ||
Boolean onAlways = false | ||
@JsonPropertyDescription("Сохранять при успешной сборке") | ||
Boolean onSuccess = false | ||
@JsonPropertyDescription("Сохранять при падении сборки") | ||
Boolean onFailure = false | ||
@JsonPropertyDescription("Сохранять при нестабильной сборке") | ||
Boolean onUnstable = false | ||
|
||
@Override | ||
@NonCPS | ||
String toString() { | ||
return "ArchiveInfobaseOptions{" + | ||
"onAlways=" + onAlways + | ||
", onSuccess=" + onSuccess + | ||
", onFailure=" + onFailure + | ||
", onUnstable=" + onUnstable + | ||
'}'; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package ru.pulsar.jenkins.library.steps | ||
|
||
import hudson.model.Result | ||
import ru.pulsar.jenkins.library.IStepExecutor | ||
import ru.pulsar.jenkins.library.configuration.ArchiveInfobaseOptions | ||
import ru.pulsar.jenkins.library.configuration.JobConfiguration | ||
import ru.pulsar.jenkins.library.ioc.ContextRegistry | ||
import ru.pulsar.jenkins.library.utils.Logger | ||
|
||
class ZipInfobase implements Serializable { | ||
|
||
private final JobConfiguration config | ||
private final String stage | ||
|
||
ZipInfobase(JobConfiguration config, String stage) { | ||
this.config = config | ||
this.stage = stage | ||
} | ||
|
||
def run() { | ||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor() | ||
|
||
Logger.printLocation() | ||
|
||
def currentBuild = steps.currentBuild() | ||
def currentResult = Result.fromString(currentBuild.getCurrentResult()) | ||
|
||
def archiveInfobaseOptions = getArchiveInfobaseOptionsForStage(config, stage) | ||
|
||
def archiveName | ||
if (stage == 'initInfoBase') { | ||
archiveName = "1Cv8.1CD.zip" | ||
} else { | ||
archiveName = "1Cv8.1CD.${stage}.zip" | ||
} | ||
|
||
// опция отвечает только за то, будет ли файл сохранен в виде артефакта | ||
def archiveInfobase = false | ||
if (archiveInfobaseOptions.onAlways | ||
|| (archiveInfobaseOptions.onFailure && (currentResult == Result.FAILURE || currentResult == Result.ABORTED)) | ||
|| (archiveInfobaseOptions.onUnstable && currentResult == Result.UNSTABLE) | ||
|| (archiveInfobaseOptions.onSuccess && currentResult == Result.SUCCESS)) { | ||
archiveInfobase = true | ||
} | ||
|
||
if (steps.fileExists(archiveName)) { | ||
steps.fileOperations([steps.fileDeleteOperation(archiveName)]) | ||
} | ||
steps.zip('build/ib', archiveName, '1Cv8.1CD', archiveInfobase) | ||
steps.stash(archiveName, archiveName, false) | ||
} | ||
|
||
private static ArchiveInfobaseOptions getArchiveInfobaseOptionsForStage(JobConfiguration config, String stageName) { | ||
|
||
def defaultOptions = new ArchiveInfobaseOptions() | ||
if (!stageName) { | ||
return defaultOptions | ||
} | ||
|
||
try { | ||
return config."${stageName}Options".archiveInfobase | ||
} catch(MissingPropertyException | NullPointerException e) { | ||
Logger.println("Ошибка при получении настроек архивации для этапа ${stageName}: ${e.message}") | ||
Logger.println(e.toString()) | ||
return defaultOptions | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.