mirror of
https://github.com/firstBitMarksistskaya/jenkins-lib.git
synced 2025-02-09 14:33:47 +02:00
Удаление экспериментов в git scm
This commit is contained in:
parent
ecc8f62e7c
commit
26e5eada5f
@ -3,8 +3,7 @@
|
||||
"srcDir": "src/cf",
|
||||
"secrets": {
|
||||
"storagePath": "UNKNOWN_ID",
|
||||
"storage": "UNKNOWN_ID",
|
||||
"lfs": "UNKNOWN_ID"
|
||||
"storage": "UNKNOWN_ID"
|
||||
},
|
||||
"stages": {
|
||||
"initSteps": false,
|
||||
@ -50,10 +49,5 @@
|
||||
"removeSupport": true,
|
||||
"supportLevel": 0
|
||||
},
|
||||
"git": {
|
||||
"lfsPull": false,
|
||||
"lfsURI": "",
|
||||
"lfsRepoURI": ""
|
||||
},
|
||||
"logosConfig": ""
|
||||
}
|
||||
|
@ -22,10 +22,6 @@
|
||||
"storage" : {
|
||||
"type" : "string",
|
||||
"description" : "Данные авторизации в хранилище конфигурации"
|
||||
},
|
||||
"lfs" : {
|
||||
"type" : "string",
|
||||
"description" : "Данные авторизации для работы с LFS"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -152,25 +148,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"git" : {
|
||||
"type" : "object",
|
||||
"id" : "urn:jsonschema:ru:pulsar:jenkins:library:configuration:GitSCMOptions",
|
||||
"description" : "Настройки git-репозитория",
|
||||
"properties" : {
|
||||
"lfsPull" : {
|
||||
"type" : "boolean",
|
||||
"description" : "Дополнительно выполнить git lfs pull"
|
||||
},
|
||||
"lfsURI" : {
|
||||
"type" : "string",
|
||||
"description" : "Адрес для получения данных LFS"
|
||||
},
|
||||
"lfsRepoURI" : {
|
||||
"type" : "string",
|
||||
"description" : "Адрес удаленного репозитория для авторизации на LFS"
|
||||
}
|
||||
}
|
||||
},
|
||||
"logosConfig" : {
|
||||
"type" : "string",
|
||||
"description" : "Конфигурация библиотеки logos. Применяется перед запуском каждой стадии сборки"
|
||||
|
@ -1,7 +1,5 @@
|
||||
package ru.pulsar.jenkins.library
|
||||
|
||||
import hudson.plugins.git.GitSCM
|
||||
import hudson.scm.SCM
|
||||
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction
|
||||
|
||||
interface IStepExecutor {
|
||||
@ -28,10 +26,6 @@ interface IStepExecutor {
|
||||
|
||||
EnvironmentAction env()
|
||||
|
||||
GitSCM scm()
|
||||
|
||||
void checkout(SCM scm)
|
||||
|
||||
void createDir(String path)
|
||||
|
||||
def withEnv(List<String> strings, Closure body)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ru.pulsar.jenkins.library
|
||||
|
||||
import hudson.plugins.git.GitSCM
|
||||
import hudson.scm.SCM
|
||||
|
||||
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction
|
||||
import ru.yandex.qatools.allure.jenkins.config.ResultsConfig
|
||||
|
||||
@ -65,16 +64,6 @@ class StepExecutor implements IStepExecutor {
|
||||
return steps.env
|
||||
}
|
||||
|
||||
@Override
|
||||
GitSCM scm() {
|
||||
return steps.scm
|
||||
}
|
||||
|
||||
@Override
|
||||
void checkout(SCM scm) {
|
||||
steps.checkout(scm)
|
||||
}
|
||||
|
||||
@Override
|
||||
void createDir(String path) {
|
||||
steps.createDir(path)
|
||||
|
@ -47,8 +47,7 @@ class ConfigurationReader implements Serializable {
|
||||
"bddOptions",
|
||||
"sonarQubeOptions",
|
||||
"syntaxCheckOptions",
|
||||
"resultsTransformOptions",
|
||||
"gitSCMOptions"
|
||||
"resultsTransformOptions"
|
||||
).toSet()
|
||||
|
||||
mergeObjects(baseConfiguration, configurationToMerge, nonMergeableSettings)
|
||||
|
@ -1,28 +0,0 @@
|
||||
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 GitSCMOptions implements Serializable {
|
||||
|
||||
@JsonPropertyDescription("Дополнительно выполнить git lfs pull")
|
||||
boolean lfsPull
|
||||
|
||||
@JsonPropertyDescription("Адрес для получения данных LFS")
|
||||
String lfsURI = ""
|
||||
|
||||
@JsonPropertyDescription("Адрес удаленного репозитория для авторизации на LFS")
|
||||
String lfsRepoURI = ""
|
||||
|
||||
@Override
|
||||
@NonCPS
|
||||
String toString() {
|
||||
return "GitSCMOptions{" +
|
||||
"lfsPull=" + lfsPull +
|
||||
"lfsURI=" + lfsURI +
|
||||
"lfsRepoURI=" + lfsRepoURI +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -40,10 +40,6 @@ class JobConfiguration implements Serializable {
|
||||
@JsonPropertyDescription("Настройки трансформации результатов анализа")
|
||||
ResultsTransformOptions resultsTransformOptions;
|
||||
|
||||
@JsonProperty("git")
|
||||
@JsonPropertyDescription("Настройки git-репозитория")
|
||||
GitSCMOptions gitSCMOptions;
|
||||
|
||||
@JsonProperty("logosConfig")
|
||||
@JsonPropertyDescription("Конфигурация библиотеки logos. Применяется перед запуском каждой стадии сборки")
|
||||
String logosConfig;
|
||||
@ -61,7 +57,6 @@ class JobConfiguration implements Serializable {
|
||||
", sonarQubeOptions=" + sonarQubeOptions +
|
||||
", syntaxCheckOptions=" + syntaxCheckOptions +
|
||||
", resultsTransformOptions=" + resultsTransformOptions +
|
||||
", gitSCMOptions=" + gitSCMOptions +
|
||||
", logosConfig=" + logosConfig +
|
||||
'}';
|
||||
}
|
||||
|
@ -13,16 +13,12 @@ class Secrets implements Serializable {
|
||||
@JsonPropertyDescription("Данные авторизации в хранилище конфигурации")
|
||||
String storage
|
||||
|
||||
@JsonPropertyDescription("Данные авторизации для работы с LFS")
|
||||
String lfs
|
||||
|
||||
@Override
|
||||
@NonCPS
|
||||
String toString() {
|
||||
return "Secrets{" +
|
||||
"storagePath='" + storagePath + '\'' +
|
||||
", storage='" + storage + '\'' +
|
||||
", lfs='" + lfs + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -1,97 +0,0 @@
|
||||
package ru.pulsar.jenkins.library.steps
|
||||
|
||||
import hudson.plugins.git.GitSCM
|
||||
import hudson.plugins.git.UserRemoteConfig
|
||||
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 Checkout implements Serializable {
|
||||
|
||||
private final JobConfiguration config;
|
||||
|
||||
Checkout(JobConfiguration config) {
|
||||
this.config = config
|
||||
}
|
||||
|
||||
def run() {
|
||||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||
|
||||
Logger.printLocation()
|
||||
|
||||
def gitSCMOptions = config.gitSCMOptions
|
||||
|
||||
if (!gitSCMOptions.lfsPull) {
|
||||
return
|
||||
}
|
||||
|
||||
def scm = steps.scm()
|
||||
|
||||
scm = addLFSRemoteConfig(scm)
|
||||
|
||||
steps.checkout(scm)
|
||||
|
||||
}
|
||||
|
||||
private GitSCM addLFSRemoteConfig(GitSCM scm) {
|
||||
def gitSCMOptions = config.gitSCMOptions
|
||||
|
||||
if (gitSCMOptions.lfsURI.isEmpty()) {
|
||||
return scm
|
||||
}
|
||||
|
||||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||
|
||||
// TODO: get git.exe path from scm settings
|
||||
steps.cmd("git config -f .lfsconfig lfs.url $gitSCMOptions.lfsURI")
|
||||
|
||||
List<UserRemoteConfig> userRemoteConfigs = new ArrayList<>(scm.getUserRemoteConfigs())
|
||||
|
||||
if (gitSCMOptions.lfsRepoURI.isEmpty()) {
|
||||
return scm
|
||||
}
|
||||
|
||||
def userRemoteConfig = userRemoteConfigs.find { it.url == gitSCMOptions.lfsRepoURI }
|
||||
boolean needToUpdateUserRemoteConfigs
|
||||
if (userRemoteConfig == null) {
|
||||
def credentialsId = config.secrets.lfs.isEmpty() ? null : config.secrets.lfs
|
||||
userRemoteConfig = new UserRemoteConfig(
|
||||
config.gitSCMOptions.lfsRepoURI,
|
||||
null,
|
||||
null,
|
||||
credentialsId
|
||||
)
|
||||
|
||||
needToUpdateUserRemoteConfigs = true
|
||||
} else {
|
||||
def credentialsId = config.secrets.lfs.isEmpty() ? userRemoteConfig.credentialsId : config.secrets.lfs
|
||||
|
||||
if (userRemoteConfig.credentialsId != credentialsId) {
|
||||
userRemoteConfig = new UserRemoteConfig(
|
||||
userRemoteConfig.url,
|
||||
null,
|
||||
userRemoteConfig.refspec,
|
||||
credentialsId
|
||||
)
|
||||
|
||||
needToUpdateUserRemoteConfigs = true
|
||||
}
|
||||
}
|
||||
|
||||
if (needToUpdateUserRemoteConfigs) {
|
||||
userRemoteConfigs.add(0, userRemoteConfig)
|
||||
scm = new GitSCM(
|
||||
userRemoteConfigs,
|
||||
scm.branches,
|
||||
scm.doGenerateSubmoduleConfigurations,
|
||||
scm.submoduleCfg,
|
||||
scm.browser,
|
||||
scm.gitTool,
|
||||
scm.extensions
|
||||
)
|
||||
}
|
||||
|
||||
return scm
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package ru.pulsar.jenkins.library.steps
|
||||
|
||||
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||
|
||||
class GitSCMExtension implements Serializable {
|
||||
|
||||
private final JobConfiguration config;
|
||||
|
||||
GitSCMExtension(JobConfiguration config) {
|
||||
this.config = config
|
||||
}
|
||||
|
||||
def run() {
|
||||
|
||||
}
|
||||
}
|
@ -41,11 +41,11 @@ class ConfigurationReaderTest {
|
||||
|
||||
assertThat(jobConfiguration.getSyntaxCheckOptions().getCheckModes()).hasSize(1);
|
||||
|
||||
assertThat(jobConfiguration.getResultsTransformOptions().isRemoveSupport()).isTrue();
|
||||
assertThat(jobConfiguration.getResultsTransformOptions().isRemoveSupport()).isFalse();
|
||||
assertThat(jobConfiguration.getResultsTransformOptions().getSupportLevel()).isZero();
|
||||
|
||||
assertThat(jobConfiguration.getInitInfobaseOptions().getRunMigration()).isFalse();
|
||||
assertThat(jobConfiguration.getInitInfobaseOptions().getAdditionalMigrationSteps()).contains("vanessa --settings ./tools/vrunner.first.json");
|
||||
assertThat(jobConfiguration.getInitInfobaseOptions().getAdditionalInitializationSteps()).contains("vanessa --settings ./tools/vrunner.first.json");
|
||||
|
||||
assertThat(jobConfiguration.getBddOptions().getVrunnerSteps()).contains("vanessa --settings ./tools/vrunner.json");
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
},
|
||||
"initInfobase": {
|
||||
"runMigration": false,
|
||||
"additionalMigrationSteps": [
|
||||
"additionalInitializationSteps": [
|
||||
"vanessa --settings ./tools/vrunner.first.json"
|
||||
]
|
||||
},
|
||||
@ -16,7 +16,7 @@
|
||||
"checkModes": ["-ThinClient"]
|
||||
},
|
||||
"resultsTransform": {
|
||||
"removeSupport": true
|
||||
"removeSupport": false
|
||||
},
|
||||
"logosConfig": "logger.rootLogger=DEBUG"
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||
import ru.pulsar.jenkins.library.steps.Checkout
|
||||
|
||||
void call(JobConfiguration config) {
|
||||
ContextRegistry.registerDefaultContext(this)
|
||||
|
||||
def checkout = new Checkout(config)
|
||||
checkout.run()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user