netdata/packaging/ci: Add some extra info on various stages, also introduce a check_login.sh step in prior to docker publishing, for early fail if credentials are messed up. Waiting the full build is overhead (#5928)
Paul Emm. Katsoulakis committed
May 1, 2019 at 07:54 UTC
0e54203dc81aeae1a989da1595a34df06f010e94
2 files changed
+53
-1
.travis.yml
+12
-1
@@ -139,7 +139,12 @@ jobs:
139
140
name: Generate changelog and TAG the release (only on special commit msg)
141
before_script: post_message "TRAVIS_MESSAGE" "Packaging step for release initiated"
142
- script: .travis/generate_changelog_and_tag_release.sh
142
+ script:
143
+ - echo "GIT Branch:" && git branch
144
+ - echo "Last commit:" && git log -1
145
+ - echo "GIT Describe:" && git describe
146
+ - echo "packaging/version:" && cat packaging/version
147
+ - .travis/generate_changelog_and_tag_release.sh
148
after_failure: post_message "TRAVIS_MESSAGE" "<!here> Packaging for release failed"
149
git:
150
depth: false
@@ -159,6 +164,7 @@ jobs:
164
- echo "Last commit:" && git log -1
165
- echo "GIT Describe:" && git describe
166
- echo "packaging/version:" && cat packaging/version
167
+ - packaging/docker/check_login.sh
168
- packaging/docker/build.sh
169
- packaging/docker/publish.sh
170
after_failure: post_message "TRAVIS_MESSAGE" "<!here> Docker image publishing failed"
@@ -216,7 +222,12 @@ jobs:
222
name: Build & Publish docker images
223
before_script: post_message "TRAVIS_MESSAGE" "Publishing docker images for nightlies"
224
script:
225
+ - echo "GIT Branch:" && git branch
226
+ - echo "Last commit:" && git log -1
227
+ - echo "GIT Describe:" && git describe
228
+ - echo "packaging/version:" && cat packaging/version
229
- docker info
230
+ - packaging/docker/check_login.sh
231
- packaging/docker/build.sh
232
- packaging/docker/publish.sh
233
after_failure: post_message "TRAVIS_MESSAGE" "<!here> Nightly docker image publish failed"
packaging/docker/check_login.sh
new
+41
@@ -0,0 +1,41 @@
1
+#!/usr/bin/env bash
2
+#
3
+# This is a credential checker script, to help get early input on docker credentials status
4
+# If these are wrong, then build/publish has no point running
5
+#
6
+# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
7
+#
8
+# Author : Pavlos Emm. Katsoulakis (paul@netdata.cloud)
9
+
10
+set -e
11
+
12
+if [ "${BASH_VERSINFO[0]}" -lt "4" ]; then
13
+ echo "This mechanism currently can only run on BASH version 4 and above"
14
+ exit 1
15
+fi
16
+
17
+DOCKER_CMD="docker "
18
+
19
+# There is no reason to continue if we cannot log in to docker hub
20
+if [ -z ${DOCKER_USERNAME+x} ] || [ -z ${DOCKER_PWD+x} ]; then
21
+ echo "No docker hub username or password found, aborting without publishing"
22
+ exit 1
23
+fi
24
+
25
+# If we are not in netdata git repo, at the top level directory, fail
26
+TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
27
+CWD=$(git rev-parse --show-cdup)
28
+if [ -n "$CWD" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
29
+ echo "Run as ./packaging/docker/$(basename "$0") from top level directory of netdata git repository"
30
+ echo "Docker build process aborted"
31
+ exit 1
32
+fi
33
+
34
+# Login to docker hub to allow futher operations
35
+echo "Attempting to login to docker"
36
+echo "$DOCKER_PWD" | $DOCKER_CMD login -u "$DOCKER_USERNAME" --password-stdin
37
+
38
+echo "Docker login successful!"
39
+$DOCKER_CMD logout
40
+
41
+echo "Docker login validation completed"