1
0

Раздельная конфигурация для lfsUri и lfsRepoUri

This commit is contained in:
Nikita Gryzlov
2020-10-29 14:01:48 +03:00
committed by kuzja086
parent ff07c64314
commit 82c5147177
4 changed files with 44 additions and 5 deletions

View File

@@ -51,6 +51,7 @@
},
"git": {
"lfsPull": false,
"lfsURI": ""
"lfsURI": "",
"lfsRepoURI": ""
}
}

View File

@@ -158,7 +158,12 @@
"description" : "Дополнительно выполнить git lfs pull"
},
"lfsURI" : {
"type" : "string"
"type" : "string",
"description" : "Адрес для получения данных LFS"
},
"lfsRepoURI" : {
"type" : "string",
"description" : "Адрес удаленного репозитория для авторизации на LFS"
}
}
}

View File

@@ -10,14 +10,19 @@ 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 +
'}';
}
}

View File

@@ -92,14 +92,42 @@ class EdtTransform implements Serializable {
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())
def userRemoteConfig = userRemoteConfigs.find { it.url == gitSCMOptions.lfsURI }
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.lfsURI, null, null, credentialsId)
userRemoteConfigs.add(0, userRemoteConfig)
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,