-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Сохранение ИБ в виде артефакта после выполнения всех шагов инциализации #149
base: develop
Are you sure you want to change the base?
Changes from 9 commits
5660e0c
ca6b1b4
b92c12e
35110ea
34dca07
738a38e
412a4c9
7a9ccaf
f77ac27
f5384e8
5b09027
2469669
845e70f
1eafa08
296660e
385bf6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 + | ||
'}'; | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
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 | ||
} | ||
|
||
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(Exception e) { | ||
Logger.println(e.message) | ||
return defaultOptions | ||
} | ||
ovcharenko-di marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ void call() { | |
timeout(time: config.timeoutOptions.zipInfoBase, unit: TimeUnit.MINUTES) { | ||
printLocation() | ||
|
||
zipInfobase() | ||
zipInfobase config, 'initInfoBase' | ||
} | ||
} | ||
} | ||
|
@@ -237,6 +237,16 @@ void call() { | |
} | ||
} | ||
} | ||
|
||
stage('Архивация ИБ') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. нет ли смысла сразу везде сделать? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. думал об этом, но лично у меня дымовые и юниты выполняются в транзакции, поэтому сохранять ИБ после этих этапов нет смысла я посчитал, что у большинства пользователей библиотеки ситуация аналогичная (могу ошибаться) |
||
steps { | ||
timeout(time: config.timeoutOptions.zipInfoBase, unit: TimeUnit.MINUTES) { | ||
printLocation() | ||
|
||
zipInfobase config, 'bdd' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут возможно имеет смысл выставить в true, т.к. при падении тестов стейдж помечается как UNSTABLE, а не FAILED. ну или по крайней мере расписать это в документации.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
согласен, выставил true тут и в initInfobase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я вот думаю, мы мастер не положим такими приколами, кстати? :)
может вырубить все по дефолту?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вырубил
<поднятьворотачутьчуть.jpg>