Errors executing populateECRCredentials via pushImage

Create issue
Issue #7 duplicate
Former user created an issue

Some problems were found with the configuration of task ':populateECRCredentials'.

No value has been specified for property 'repository'. No value has been specified for property 'registryId'. No value has been specified for property 'registryUrl'.

This is my config

def lastExitCode = 0 def TARGET_ENVIRONMENTS = [:] TARGET_ENVIRONMENTS['Nexus'] = [dockerImageName: XXX/YYY', dockerImageTag: 'sprint9', targetRepository: 'ZZZ'] TARGET_ENVIRONMENTS['AWSPRE'] = [dockerImageName: ' XXX/YYY', dockerImageTag: 'sprint9', targetRepository: 'ZZZ' + '.amazonaws.com']

buildscript { repositories { jcenter() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath 'com.bmuschko:gradle-docker-plugin:3.0.6' classpath "gradle.plugin.com.patdouble:gradle-aws-ecr-plugin:0.3.2" } }

repositories { maven { url 'https://repo.gradle.org/gradle/libs-releases-local' } mavenCentral() }

ext { socatContainerName = 'socat' }

apply plugin: com.bmuschko.gradle.docker.DockerRemoteApiPlugin apply plugin: com.patdouble.gradle.awsecr.AwsecrPlugin

docker { registryCredentials { url = 'https://123456789012.dkr.ecr.us-east-1.amazonaws.com' } }

import com.bmuschko.gradle.docker.response. import com.bmuschko.gradle.docker.tasks.container. import com.bmuschko.gradle.docker.tasks.image.* import com.patdouble.gradle.awsecr.PopulateECRCredentials

class CheckDockerContainer extends DockerInspectContainer {

boolean exists = false
boolean running = false

public CheckDockerContainer() {
    setResponseHandler(
            new ResponseHandler<Void, Object>() {
                @Override
                Void handle(Object container) {
                    exists = container?.state
                    running = container?.state?.running
                }
            })
}

@Override
public void start() {
    try {
        super.start()
    } catch (Throwable error) {
        if (error.class.name.endsWith("NotFoundException")) {
            exists = false
            running = false
        }
    }
}

}

// Check socat container task checkSocatContainer(type: CheckDockerContainer) { targetContainerId { '' + socatContainerName } }

// Create one start and one stop Task per DB environment TARGET_ENVIRONMENTS.each { envName, envProps -> tasks.create(name: "buildImage$envName", type: DockerBuildImage, group: DOCKER_GROUP) { dependsOn bootRepackage dependsOn checkSocatContainer

    doFirst {
        if ((lastExitCode != 0) || (!checkSocatContainer.exists) || (!checkSocatContainer.running)) {
            throw new GradleException("Socat container must be running in order to build images. If you already have one, start it:\n\n" +
                    " > docker start socat\n\n" +
                    "If you don't have an existing socat container, run it in this way:\n\n" +
                    " > docker run -d --name socat -v /var/run/docker.sock:/var/run/docker.sock -p 2375:2375 bobrik/socat TCP4-LISTEN:2375,fork,reuseaddr UNIX-CONNECT:/var/run/docker.sock")
        }
    }

    inputDir = file('.')
    tag = envProps.dockerImageName
}

tasks.create(name: "tagImage$envName", type: DockerTagImage, group: DOCKER_GROUP) {
    dependsOn "buildImage$envName"

    force = true
    tag = envProps.dockerImageTag
    imageId = envProps.dockerImageName
    repository = "${envProps.targetRepository}/${imageId}"
}

tasks.create(name: "pushImage$envName", type: DefaultTask) {
    dependsOn "tagImage$envName"

    doLast {

        exec {
            commandLine DOCKER, 'push', "${envProps.targetRepository}/${envProps.dockerImageName}:${envProps.dockerImageTag}"
        }
    }
}

}

Comments (1)

  1. Log in to comment