ACS-550 Disable Docker image push on Continuous Releases

This commit is contained in:
Cezar.Leahu
2020-09-09 20:56:51 +03:00
parent cfd9508585
commit 53c39f98a0
3 changed files with 27 additions and 56 deletions

View File

@@ -189,16 +189,15 @@
</build> </build>
</image> </image>
<!-- DockerHub image --> <!-- DockerHub image -->
<!-- todo enable when the dockerhub credentials are set on the project --> <image>
<!-- <image>--> <name>${image.name}:${image.tag}</name>
<!-- <name>${image.name}:${image.tag}</name>--> <build>
<!-- <build>--> <dockerFileDir>${project.basedir}/</dockerFileDir>
<!-- <dockerFileDir>${project.basedir}/</dockerFileDir>--> <buildOptions>
<!-- <buildOptions>--> <squash>true</squash>
<!-- <squash>true</squash>--> </buildOptions>
<!-- </buildOptions>--> </build>
<!-- </build>--> </image>
<!-- </image>-->
</images> </images>
</configuration> </configuration>
<executions> <executions>
@@ -217,7 +216,7 @@
</profile> </profile>
<profile> <profile>
<id>release</id> <id>releaseImage</id>
<!-- publishes "image:release_version" on Quay & DockerHub --> <!-- publishes "image:release_version" on Quay & DockerHub -->
<build> <build>
<plugins> <plugins>
@@ -238,16 +237,15 @@
</build> </build>
</image> </image>
<!-- DockerHub image --> <!-- DockerHub image -->
<!-- todo enable when the dockerhub credentials are set on the project --> <image>
<!-- <image>--> <name>${image.name}:${project.version}</name>
<!-- <name>${image.name}:${project.version}</name>--> <build>
<!-- <build>--> <dockerFileDir>${project.basedir}/</dockerFileDir>
<!-- <dockerFileDir>${project.basedir}/</dockerFileDir>--> <buildOptions>
<!-- <buildOptions>--> <squash>true</squash>
<!-- <squash>true</squash>--> </buildOptions>
<!-- </buildOptions>--> </build>
<!-- </build>--> </image>
<!-- </image>-->
</images> </images>
</configuration> </configuration>
<executions> <executions>
@@ -256,7 +254,8 @@
<phase>deploy</phase> <phase>deploy</phase>
<goals> <goals>
<goal>build</goal> <goal>build</goal>
<goal>push</goal> <!-- Image push is DISABLED, so Continuous Releases don't pollute the repository -->
<!--<goal>push</goal>-->
</goals> </goals>
</execution> </execution>
</executions> </executions>

View File

@@ -12,8 +12,8 @@ git config user.email "${GIT_EMAIL}"
# Run the release plugin - with "[skip ci]" in the release commit message # Run the release plugin - with "[skip ci]" in the release commit message
mvn -B \ mvn -B \
-Prelease,fullBuild,all-tas-tests \ -PfullBuild,all-tas-tests \
"-Darguments=-Prelease,fullBuild,all-tas-tests -DskipTests -Dbuild-number=${TRAVIS_BUILD_NUMBER}" \ "-Darguments=-PfullBuild,all-tas-tests -DskipTests -Dbuild-number=${TRAVIS_BUILD_NUMBER}" \
release:clean release:prepare release:perform \ release:clean release:prepare release:perform \
-DscmCommentPrefix="[maven-release-plugin][skip ci] " \ -DscmCommentPrefix="[maven-release-plugin][skip ci] " \
-Dusername="${GIT_USERNAME}" \ -Dusername="${GIT_USERNAME}" \

View File

@@ -5,47 +5,19 @@ set -vex
pushd "$(dirname "${BASH_SOURCE[0]}")/../../" pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
# #
# Check that the version to be released does not already have a docker tag. # Check that the version to be released does not already have a git tag.
# #
POM_VERSION=$(mvn -B -q help:evaluate -Dexpression=project.version -DforceStdout) POM_VERSION=$(mvn -B -q help:evaluate -Dexpression=project.version -DforceStdout)
printf "POM version: %s\n" "${POM_VERSION}" printf "POM version: %s\n" "${POM_VERSION}"
IMAGE_TAG="${POM_VERSION%-SNAPSHOT}" TAG="${POM_VERSION%-SNAPSHOT}"
if git rev-parse "${IMAGE_TAG}^{tag}" &>/dev/null ; then if git rev-parse "${TAG}^{tag}" &>/dev/null ; then
echo "The next tag \"${IMAGE_TAG}\" already exists in the git project" echo "The next tag \"${TAG}\" already exists in the git project"
exit 1 exit 1
fi fi
# get the image name from the pom file
ALFRESCO_DOCKER_IMAGE="$(mvn -B -q help:evaluate -f ./packaging/docker-alfresco/pom.xml -Dexpression=image.name -DforceStdout)"
DOCKER_IMAGE_FULL_NAME="${ALFRESCO_DOCKER_IMAGE}:${IMAGE_TAG}"
function docker_image_exists() {
local IMAGE_FULL_NAME="${1}"; shift
local WAIT_TIME="${1:-5}"
local SEARCH_TERM='Pulling|is up to date|not found'
echo "Looking to see if ${IMAGE_FULL_NAME} already exists..."
local RESULT=$( (timeout --preserve-status "${WAIT_TIME}" docker 2>&1 pull "${IMAGE_FULL_NAME}" &) | grep -v 'Pulling repository' | grep -E -o "${SEARCH_TERM}")
test "${RESULT}" || { echo "Timed out too soon. Try using a wait_time greater than ${WAIT_TIME}..."; return 1 ;}
if echo "${RESULT}" | grep -vq 'not found'; then
true
else
false
fi
}
if docker_image_exists "${DOCKER_IMAGE_FULL_NAME}" ; then
echo "Tag ${RELEASE_VERSION} already pushed, release process will interrupt."
exit 1
else
echo "The ${RELEASE_VERSION} tag was not found"
fi
popd popd
set +vex set +vex
echo "=========================== Finishing Verify Release Tag Script ==========================" echo "=========================== Finishing Verify Release Tag Script =========================="