6
6
# Uses the following Travis secure variables:
7
7
# - DOCKER_USERNAME
8
8
# - DOCKER_PASSWORD
9
- # - GITHUB_TOKEN
10
9
#
11
10
# These are set via https://travis-ci.com/OpenGrok/docker/settings
12
11
#
@@ -16,36 +15,27 @@ set -e
16
15
17
16
# Travis can only work on master since it needs encrypted variables.
18
17
if [ " ${TRAVIS_PULL_REQUEST} " != " false" ]; then
18
+ print " Not build docker image for pull requests"
19
19
exit 0
20
20
fi
21
21
22
- JSON_OUT= " ver.out "
23
-
22
+ # Build the image.
23
+ docker build -t opengrok/docker: $VERSION -t opengrok/docker:latest .
24
24
#
25
- # Get the latest OpenGrok version string. Use authenticated request to avoid
26
- # rate limiting induced errors .
25
+ # Run the image in container. This is not strictly needed however
26
+ # serves as additional test in automatic builds .
27
27
#
28
- curl -sS -o " $JSON_OUT " \
29
- -H " Authorization: token $GITHUB_TOKEN " \
30
- https://api.github.com/repos/oracle/opengrok/releases/latest
31
- cat " $JSON_OUT "
32
- VERSION=` jq -er .tag_name ver.out`
33
- echo " Latest OpenGrok tag: $VERSION "
34
-
35
- # Embed the tarball URL into the Dockerfile.
36
- tarball=` jq -er ' .assets[]|select(.name|test("opengrok-.*tar.gz"))|.browser_download_url' " $JSON_OUT " `
37
- echo " Tarball URL: $tarball "
38
- sed " s%OPENGROK_DOWNLOAD_LINK%$tarball %" Dockerfile.tmpl > Dockerfile
39
-
40
- # Build and run the image in container.
41
- docker build -t opengrok/docker:$VERSION -t opengrok/docker:latest .
42
28
docker run -d opengrok/docker
43
29
docker ps -a
44
30
45
31
# Publish the image to Docker hub.
46
32
if [ -n " $DOCKER_PASSWORD " -a -n " $DOCKER_USERNAME " -a -n " $VERSION " ]; then
47
- echo " Pushing image for version $VERSION "
33
+ echo " Logging into docker "
48
34
echo " $DOCKER_PASSWORD " | docker login -u " $DOCKER_USERNAME " --password-stdin
35
+
36
+ # All the tags need to be pushed individually:
37
+ echo " Pushing docker image for tag $VERSION "
49
38
docker push opengrok/docker:$VERSION
39
+ echo " Pushing docker image for tag latest"
50
40
docker push opengrok/docker:latest
51
41
fi
0 commit comments