initial commit
This commit is contained in:
29
src/main/groovy/util/DockerLogin.groovy
Normal file
29
src/main/groovy/util/DockerLogin.groovy
Normal file
@@ -0,0 +1,29 @@
|
||||
package util
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.transform.Memoized
|
||||
|
||||
@CompileStatic
|
||||
class DockerLogin {
|
||||
|
||||
static void perform() {
|
||||
loginDockerInternal()
|
||||
}
|
||||
|
||||
@Memoized
|
||||
private static Object loginDockerInternal() {
|
||||
// Проверяем на всякий случай, что докер вообще установлен
|
||||
if (System.findExecutablesInPath(['docker']).isEmpty())
|
||||
throw new FileNotFoundException("Can't find installed docker-compose at that system!")
|
||||
|
||||
// Логинимся в Registry
|
||||
ScriptLog.printf "Performing login to registry..."
|
||||
def registryName = System.getGlobalProperty("ci.docker.registry")
|
||||
def registryUser = System.getGlobalProperty("ci.docker.registry.username")
|
||||
def registryPassword = System.getGlobalProperty("ci.docker.registry.password")
|
||||
|
||||
sh "docker login $registryName -u $registryUser -p $registryPassword"
|
||||
|
||||
ScriptLog.printf "Login into docker registry '${registryName}' successful!"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user