1
0

Вынос методов-креденшелов в Steps

This commit is contained in:
Nikita Gryzlov
2021-11-08 17:01:00 +03:00
parent a94909ff6e
commit 63c230e8ce
3 changed files with 25 additions and 14 deletions

View File

@@ -1,6 +1,5 @@
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
@@ -30,7 +29,11 @@ interface IStepExecutor {
void tool(String toolName)
def withCredentials(List<MultiBinding> bindings, Closure body)
def withCredentials(List bindings, Closure body)
def string(String credentialsId, String variable)
def usernamePassword(String credentialsId, String usernameVariable, String passwordVariable)
void withSonarQubeEnv(String installationName, Closure body)

View File

@@ -1,6 +1,5 @@
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
@@ -71,12 +70,22 @@ class StepExecutor implements IStepExecutor {
}
@Override
def withCredentials(List<MultiBinding> bindings, Closure body) {
def withCredentials(List bindings, Closure body) {
steps.withCredentials(bindings) {
body()
}
}
@Override
def string(String credentialsId, String variable) {
return steps.string(credentialsId: credentialsId, variable: variable)
}
@Override
def usernamePassword(String credentialsId, String usernameVariable, String passwordVariable) {
return steps.string(credentialsId: credentialsId, usernameVariable: usernameVariable, passwordVariable: passwordVariable)
}
@Override
EnvironmentAction env() {
return steps.env

View File

@@ -1,7 +1,6 @@
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
@@ -32,17 +31,17 @@ class InitFromStorage implements Serializable {
def storageVersion = VersionParser.storage()
def storageVersionParameter = storageVersion == "" ? "" : "--storage-ver $storageVersion"
steps.withCredentials(Arrays.asList(
new UsernamePasswordMultiBinding(
steps.withCredentials([
steps.usernamePassword(
config.secrets.storage,
'STORAGE_USR',
'STORAGE_PSW',
config.secrets.storage
'STORAGE_PSW'
),
new StringBinding(
'STORAGE_PATH',
config.secrets.storagePath
steps.string(
config.secrets.storagePath,
'STORAGE_PATH'
)
)) {
]) {
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\""
}