forked from firstBitMarksistskaya/jenkins-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca6b1b4
commit b92c12e
Showing
9 changed files
with
144 additions
and
25 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package ru.pulsar.jenkins.library.steps | ||
|
||
import hudson.model.Result | ||
import ru.pulsar.jenkins.library.IStepExecutor | ||
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 = options.archiveInfobase | ||
|
||
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 | ||
} | ||
|
||
def archiveName = "1Cv8.1CD.${stage}.zip" | ||
steps.zip('build/ib', '1Cv8.1CD', archiveName, archiveInfobase) | ||
steps.stash(archiveName, archiveName, false) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import ru.pulsar.jenkins.library.configuration.JobConfiguration | ||
import ru.pulsar.jenkins.library.ioc.ContextRegistry | ||
import ru.pulsar.jenkins.library.steps.ZipInfobase | ||
|
||
def call(JobConfiguration config) { | ||
|
||
def archiveName = '1Cv8.1CD.zip' | ||
|
||
zip dir: 'build/ib', glob: '1Cv8.1CD', zipFile: archiveName, archive: config.initInfoBaseOptions.archiveInfobase | ||
stash name: archiveName, includes: archiveName, allowEmpty: false | ||
def call(JobConfiguration config, String stageName) { | ||
ContextRegistry.registerDefaultContext(this) | ||
|
||
def zipInfobase = new ZipInfobase(config, stageName) | ||
zipInfobase.run() | ||
} |