You've already forked jenkins-lib
mirror of
https://github.com/firstBitMarksistskaya/jenkins-lib.git
synced 2025-07-14 06:04:15 +02:00
Перенос инициализации из хранилища в отдельный класс
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
package ru.pulsar.jenkins.library
|
package ru.pulsar.jenkins.library
|
||||||
|
|
||||||
|
import org.jenkinsci.plugins.credentialsbinding.MultiBinding
|
||||||
import org.jenkinsci.plugins.pipeline.utility.steps.fs.FileWrapper
|
import org.jenkinsci.plugins.pipeline.utility.steps.fs.FileWrapper
|
||||||
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction
|
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction
|
||||||
|
|
||||||
@ -29,6 +30,8 @@ interface IStepExecutor {
|
|||||||
|
|
||||||
void tool(String toolName)
|
void tool(String toolName)
|
||||||
|
|
||||||
|
def withCredentials(List<MultiBinding> bindings, Closure body)
|
||||||
|
|
||||||
void withSonarQubeEnv(String installationName, Closure body)
|
void withSonarQubeEnv(String installationName, Closure body)
|
||||||
|
|
||||||
EnvironmentAction env()
|
EnvironmentAction env()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ru.pulsar.jenkins.library
|
package ru.pulsar.jenkins.library
|
||||||
|
|
||||||
|
import org.jenkinsci.plugins.credentialsbinding.MultiBinding
|
||||||
import org.jenkinsci.plugins.pipeline.utility.steps.fs.FileWrapper
|
import org.jenkinsci.plugins.pipeline.utility.steps.fs.FileWrapper
|
||||||
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction
|
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction
|
||||||
import ru.yandex.qatools.allure.jenkins.config.ResultsConfig
|
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
|
@Override
|
||||||
EnvironmentAction env() {
|
EnvironmentAction env() {
|
||||||
return steps.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.configuration.JobConfiguration
|
||||||
import ru.pulsar.jenkins.library.utils.VRunner
|
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||||
import ru.pulsar.jenkins.library.utils.VersionParser
|
import ru.pulsar.jenkins.library.steps.InitFromStorage
|
||||||
|
|
||||||
def call(JobConfiguration jobConfiguration) {
|
def call(JobConfiguration config) {
|
||||||
|
ContextRegistry.registerDefaultContext(this)
|
||||||
|
|
||||||
printLocation()
|
def initFromStorage = new InitFromStorage(config)
|
||||||
|
initFromStorage.run()
|
||||||
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\""
|
|
||||||
}
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user