You've already forked jenkins-lib
forked from jenkins/jenkins-lib
Раздельная конфигурация для lfsUri и lfsRepoUri
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
},
|
||||
"git": {
|
||||
"lfsPull": false,
|
||||
"lfsURI": ""
|
||||
"lfsURI": "",
|
||||
"lfsRepoURI": ""
|
||||
}
|
||||
}
|
||||
|
@@ -158,7 +158,12 @@
|
||||
"description" : "Дополнительно выполнить git lfs pull"
|
||||
},
|
||||
"lfsURI" : {
|
||||
"type" : "string"
|
||||
"type" : "string",
|
||||
"description" : "Адрес для получения данных LFS"
|
||||
},
|
||||
"lfsRepoURI" : {
|
||||
"type" : "string",
|
||||
"description" : "Адрес удаленного репозитория для авторизации на LFS"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user