mirror of
https://github.com/firstBitMarksistskaya/jenkins-lib.git
synced 2024-11-28 09:33:03 +02:00
Перенос инициализации из хранилища в отдельный класс
This commit is contained in:
parent
8014122759
commit
a94909ff6e
@ -1,5 +1,6 @@
|
||||
package ru.pulsar.jenkins.library
|
||||
|
||||
import org.jenkinsci.plugins.credentialsbinding.MultiBinding
|
||||
import org.jenkinsci.plugins.pipeline.utility.steps.fs.FileWrapper
|
||||
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction
|
||||
|
||||
@ -29,6 +30,8 @@ interface IStepExecutor {
|
||||
|
||||
void tool(String toolName)
|
||||
|
||||
def withCredentials(List<MultiBinding> bindings, Closure body)
|
||||
|
||||
void withSonarQubeEnv(String installationName, Closure body)
|
||||
|
||||
EnvironmentAction env()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.pulsar.jenkins.library
|
||||
|
||||
import org.jenkinsci.plugins.credentialsbinding.MultiBinding
|
||||
import org.jenkinsci.plugins.pipeline.utility.steps.fs.FileWrapper
|
||||
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction
|
||||
import ru.yandex.qatools.allure.jenkins.config.ResultsConfig
|
||||
@ -69,6 +70,13 @@ class StepExecutor implements IStepExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
def withCredentials(List<MultiBinding> bindings, Closure body) {
|
||||
steps.withCredentials(bindings) {
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
EnvironmentAction env() {
|
||||
return steps.env
|
||||
|
50
src/ru/pulsar/jenkins/library/steps/InitFromStorage.groovy
Normal file
50
src/ru/pulsar/jenkins/library/steps/InitFromStorage.groovy
Normal file
@ -0,0 +1,50 @@
|
||||
package ru.pulsar.jenkins.library.steps
|
||||
|
||||
import org.jenkinsci.plugins.credentialsbinding.impl.StringBinding
|
||||
import org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding
|
||||
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
|
||||
import ru.pulsar.jenkins.library.utils.VRunner
|
||||
import ru.pulsar.jenkins.library.utils.VersionParser
|
||||
|
||||
class InitFromStorage implements Serializable {
|
||||
|
||||
private final JobConfiguration config;
|
||||
|
||||
InitFromStorage(JobConfiguration config) {
|
||||
this.config = config
|
||||
}
|
||||
|
||||
def run() {
|
||||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||
|
||||
Logger.printLocation()
|
||||
|
||||
if (config.infobaseFromFiles()) {
|
||||
Logger.println("init infoBase from storage is disabled")
|
||||
return
|
||||
}
|
||||
|
||||
steps.installLocalDependencies();
|
||||
|
||||
def storageVersion = VersionParser.storage()
|
||||
def storageVersionParameter = storageVersion == "" ? "" : "--storage-ver $storageVersion"
|
||||
|
||||
steps.withCredentials(Arrays.asList(
|
||||
new UsernamePasswordMultiBinding(
|
||||
'STORAGE_USR',
|
||||
'STORAGE_PSW',
|
||||
config.secrets.storage
|
||||
),
|
||||
new StringBinding(
|
||||
'STORAGE_PATH',
|
||||
config.secrets.storagePath
|
||||
)
|
||||
)) {
|
||||
String vrunnerPath = VRunner.getVRunnerPath();
|
||||
steps.cmd "$vrunnerPath init-dev --storage --storage-name $STORAGE_PATH --storage-user $STORAGE_USR --storage-pwd $STORAGE_PSW $storageVersionParameter --ibconnection \"/F./build/ib\""
|
||||
}
|
||||
}
|
||||
}
|
@ -1,28 +1,10 @@
|
||||
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||
import ru.pulsar.jenkins.library.utils.VRunner
|
||||
import ru.pulsar.jenkins.library.utils.VersionParser
|
||||
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||
import ru.pulsar.jenkins.library.steps.InitFromStorage
|
||||
|
||||
def call(JobConfiguration jobConfiguration) {
|
||||
def call(JobConfiguration config) {
|
||||
ContextRegistry.registerDefaultContext(this)
|
||||
|
||||
printLocation()
|
||||
|
||||
installLocalDependencies();
|
||||
|
||||
def storageVersion = VersionParser.storage()
|
||||
def storageVersionParameter = storageVersion == "" ? "" : "--storage-ver $storageVersion"
|
||||
|
||||
withCredentials([
|
||||
usernamePassword(
|
||||
credentialsId: jobConfiguration.secrets.storage,
|
||||
passwordVariable: 'STORAGE_PSW',
|
||||
usernameVariable: 'STORAGE_USR'
|
||||
),
|
||||
string(
|
||||
credentialsId: jobConfiguration.secrets.storagePath,
|
||||
variable: 'STORAGE_PATH'
|
||||
)
|
||||
]) {
|
||||
String vrunnerPath = VRunner.getVRunnerPath();
|
||||
cmd "$vrunnerPath init-dev --storage --storage-name $STORAGE_PATH --storage-user $STORAGE_USR --storage-pwd $STORAGE_PSW $storageVersionParameter --ibconnection \"/F./build/ib\""
|
||||
}
|
||||
def initFromStorage = new InitFromStorage(config)
|
||||
initFromStorage.run()
|
||||
}
|
Loading…
Reference in New Issue
Block a user