From 63c230e8ce740a6311664c5d55569473bf2a3f31 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Mon, 8 Nov 2021 17:01:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=BD=D0=BE=D1=81=20=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=B4=D0=BE=D0=B2-=D0=BA=D1=80=D0=B5=D0=B4=D0=B5?= =?UTF-8?q?=D0=BD=D1=88=D0=B5=D0=BB=D0=BE=D0=B2=20=D0=B2=20Steps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jenkins/library/IStepExecutor.groovy | 7 +++++-- .../jenkins/library/StepExecutor.groovy | 13 +++++++++++-- .../library/steps/InitFromStorage.groovy | 19 +++++++++---------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy index 53af9f4..243763b 100644 --- a/src/ru/pulsar/jenkins/library/IStepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/IStepExecutor.groovy @@ -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 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) diff --git a/src/ru/pulsar/jenkins/library/StepExecutor.groovy b/src/ru/pulsar/jenkins/library/StepExecutor.groovy index f61b12b..21c5a58 100644 --- a/src/ru/pulsar/jenkins/library/StepExecutor.groovy +++ b/src/ru/pulsar/jenkins/library/StepExecutor.groovy @@ -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 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 diff --git a/src/ru/pulsar/jenkins/library/steps/InitFromStorage.groovy b/src/ru/pulsar/jenkins/library/steps/InitFromStorage.groovy index 48537d1..13b5112 100644 --- a/src/ru/pulsar/jenkins/library/steps/InitFromStorage.groovy +++ b/src/ru/pulsar/jenkins/library/steps/InitFromStorage.groovy @@ -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\"" }