Skip to content

Commit c782a32

Browse files
dselvara1GitHub Enterprise
authored andcommitted
Merge pull request #815 from mq-cloudpak/sdp-fix-travis-issue-v941
Fix travis issues
2 parents 60be2f6 + 088aba3 commit c782a32

File tree

8 files changed

+114
-25
lines changed

8 files changed

+114
-25
lines changed

.travis.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
dist: bionic
16-
group: beta
15+
dist: focal
16+
group: vpc
1717
sudo: required
1818

1919
go:
@@ -28,7 +28,6 @@ env:
2828
- TAGCACHE_FILE=tagcache
2929
- RELEASE=r1
3030
- BASE_MQ_LOCKED=false
31-
- GO_VERSION="1.22.9"
3231

3332
go_import_path: "github.com/ibm-messaging/mq-container"
3433

@@ -46,7 +45,9 @@ jobs:
4645
os: linux
4746
env:
4847
- MQ_ARCHIVE_REPOSITORY_DEV=$MQ_9_4_1_ARCHIVE_REPOSITORY_DEV_AMD64
49-
script: bash -e travis-build-scripts/run.sh
48+
script:
49+
- bash travis-build-scripts/travis-log-keepalive.sh &
50+
- bash -e travis-build-scripts/run.sh
5051

5152
# CD Build
5253

@@ -175,10 +176,9 @@ jobs:
175176

176177
before_install:
177178
- make go-install
178-
- curl -sL -o ~/bin/gimme https://raw.githubusercontent.com/urfave/gimme/main/gimme
179-
- chmod +x ~/bin/gimme
180-
- gimme version
181-
- eval "$(gimme "$GO_VERSION")"
179+
- export PATH=/usr/local/go/bin:$PATH
180+
- export GOROOT=/usr/local/go
181+
- export GOPATH=$HOME/gopath
182182
- go env
183183
- make install-build-deps
184184
- make install-credential-helper

Makefile

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ MQ_DELIVERY_REGISTRY_CREDENTIAL ?=
7171
LTS ?= false
7272
# VOLUME_MOUNT_OPTIONS is used when bind-mounting files from the "downloads" directory into the container. By default, SELinux labels are automatically re-written, but this doesn't work on some filesystems with extended attributes (xattrs). You can turn off the label re-writing by setting this variable to be blank.
7373
VOLUME_MOUNT_OPTIONS ?= :Z
74+
# Cache path for pushing images
75+
MQ_BUILD_REGISTRY_PATH = $(MQ_BUILD_REGISTRY_HOSTNAME)/$(MQ_BUILD_REGISTRY_NAMESPACE)/$(TRAVIS_BUILD_ID)
7476

7577
###############################################################################
7678
# Other variables
@@ -456,23 +458,51 @@ pull-mq-archive-dev:
456458

457459
.PHONY: push-advancedserver
458460
push-advancedserver:
459-
@if [ $(MQ_DELIVERY_REGISTRY_NAMESPACE) = "master-fake" ]; then\
460-
echo "Detected fake master build. Note that the push destination is set to the fake master namespace: $(MQ_DELIVERY_REGISTRY_FULL_PATH)";\
461-
fi
462-
$(info $(SPACER)$(shell printf $(TITLE)"Push production image to $(MQ_DELIVERY_REGISTRY_FULL_PATH)"$(END)))
461+
ifndef BUILD_INTERNAL_LEVEL
462+
$(info $(SPACER)$(shell printf $(TITLE)"Push production image to cache repository $(MQ_BUILD_REGISTRY_PATH)"$(END)))
463+
$(COMMAND) login $(MQ_DELIVERY_REGISTRY_HOSTNAME) -u $(MQ_DELIVERY_REGISTRY_USER) -p $(MQ_DELIVERY_REGISTRY_CREDENTIAL)
464+
$(COMMAND) tag $(MQ_IMAGE_ADVANCEDSERVER)\:$(MQ_TAG) $(MQ_BUILD_REGISTRY_PATH)/$(MQ_IMAGE_FULL_RELEASE_NAME)
465+
$(COMMAND) push $(MQ_BUILD_REGISTRY_PATH)/$(MQ_IMAGE_FULL_RELEASE_NAME)
466+
else
467+
$(info $(SPACER)$(shell printf $(TITLE)"Push production image to base mq team repository $(MQ_DELIVERY_REGISTRY_FULL_PATH)"$(END)))
463468
$(COMMAND) login $(MQ_DELIVERY_REGISTRY_HOSTNAME) -u $(MQ_DELIVERY_REGISTRY_USER) -p $(MQ_DELIVERY_REGISTRY_CREDENTIAL)
464469
$(COMMAND) tag $(MQ_IMAGE_ADVANCEDSERVER)\:$(MQ_TAG) $(MQ_DELIVERY_REGISTRY_FULL_PATH)/$(MQ_IMAGE_FULL_RELEASE_NAME)
465470
$(COMMAND) push $(MQ_DELIVERY_REGISTRY_FULL_PATH)/$(MQ_IMAGE_FULL_RELEASE_NAME)
471+
endif
466472

467473
.PHONY: push-devserver
468474
push-devserver:
469-
@if [ $(MQ_DELIVERY_REGISTRY_NAMESPACE) = "master-fake" ]; then\
470-
echo "Detected fake master build. Note that the push destination is set to the fake master namespace: $(MQ_DELIVERY_REGISTRY_FULL_PATH)";\
471-
fi
472-
$(info $(SPACER)$(shell printf $(TITLE)"Push developer image to $(MQ_DELIVERY_REGISTRY_FULL_PATH)"$(END)))
475+
ifndef BUILD_INTERNAL_LEVEL
476+
$(info $(SPACER)$(shell printf $(TITLE)"Push developer image to cache repository $(MQ_BUILD_REGISTRY_PATH)"$(END)))
477+
$(COMMAND) login $(MQ_DELIVERY_REGISTRY_HOSTNAME) -u $(MQ_DELIVERY_REGISTRY_USER) -p $(MQ_DELIVERY_REGISTRY_CREDENTIAL)
478+
$(COMMAND) tag $(MQ_IMAGE_DEVSERVER)\:$(MQ_TAG) $(MQ_BUILD_REGISTRY_PATH)/$(MQ_IMAGE_DEV_FULL_RELEASE_NAME)
479+
$(COMMAND) push $(MQ_BUILD_REGISTRY_PATH)/$(MQ_IMAGE_DEV_FULL_RELEASE_NAME)
480+
else
481+
$(info $(SPACER)$(shell printf $(TITLE)"Push developer image to base mq team repository $(MQ_DELIVERY_REGISTRY_FULL_PATH)"$(END)))
473482
$(COMMAND) login $(MQ_DELIVERY_REGISTRY_HOSTNAME) -u $(MQ_DELIVERY_REGISTRY_USER) -p $(MQ_DELIVERY_REGISTRY_CREDENTIAL)
474483
$(COMMAND) tag $(MQ_IMAGE_DEVSERVER)\:$(MQ_TAG) $(MQ_DELIVERY_REGISTRY_FULL_PATH)/$(MQ_IMAGE_DEV_FULL_RELEASE_NAME)
475484
$(COMMAND) push $(MQ_DELIVERY_REGISTRY_FULL_PATH)/$(MQ_IMAGE_DEV_FULL_RELEASE_NAME)
485+
endif
486+
487+
.PHONY: promote-devserver
488+
promote-devserver: build-skopeo-container
489+
@if [ $(MQ_DELIVERY_REGISTRY_NAMESPACE) = "master-fake" ]; then\
490+
echo "Detected fake master build. Note that the push destination is set to the fake master namespace: $(MQ_DELIVERY_REGISTRY_FULL_PATH)";\
491+
fi
492+
$(eval MQ_IMAGE_DEVSERVER_DIGEST=$(shell $(COMMAND) run skopeo:latest --override-os linux inspect --creds $(MQ_DELIVERY_REGISTRY_USER):$(MQ_DELIVERY_REGISTRY_CREDENTIAL) docker://$(MQ_BUILD_REGISTRY_PATH)/$(MQ_IMAGE_DEV_FULL_RELEASE_NAME) | jq -r .Digest))
493+
$(info $(shell printf "** Determined the built $(MQ_IMAGE_DEV_FULL_RELEASE_NAME) has a digest of $(MQ_IMAGE_DEVSERVER_DIGEST)**"$(END)))
494+
@printf $(TITLE)"\nCopying $(MQ_IMAGE_DEV_FULL_RELEASE_NAME) image with digest $(MQ_IMAGE_DEVSERVER_DIGEST) to \"$(MQ_DELIVERY_REGISTRY_HOSTNAME)\"\n"$(END)
495+
docker run skopeo:latest copy --src-creds $(MQ_DELIVERY_REGISTRY_USER):$(MQ_DELIVERY_REGISTRY_CREDENTIAL) --dest-creds $(MQ_DELIVERY_REGISTRY_USER):$(MQ_DELIVERY_REGISTRY_CREDENTIAL) docker://$(MQ_BUILD_REGISTRY_PATH)/$(MQ_IMAGE_DEVSERVER)@$(MQ_IMAGE_DEVSERVER_DIGEST) docker://$(MQ_DELIVERY_REGISTRY_FULL_PATH)/$(MQ_IMAGE_DEV_FULL_RELEASE_NAME)
496+
497+
.PHONY: promote-advancedserver
498+
promote-advancedserver: build-skopeo-container
499+
@if [ $(MQ_DELIVERY_REGISTRY_NAMESPACE) = "master-fake" ]; then\
500+
echo "Detected fake master build. Note that the push destination is set to the fake master namespace: $(MQ_DELIVERY_REGISTRY_FULL_PATH)";\
501+
fi
502+
$(eval MQ_IMAGE_ADVANCEDSERVER_DIGEST=$(shell $(COMMAND) run skopeo:latest --override-os linux inspect --creds $(MQ_DELIVERY_REGISTRY_USER):$(MQ_DELIVERY_REGISTRY_CREDENTIAL) docker://$(MQ_BUILD_REGISTRY_PATH)/$(MQ_IMAGE_FULL_RELEASE_NAME) | jq -r .Digest))
503+
$(info $(shell printf "** Determined the built $(MQ_IMAGE_FULL_RELEASE_NAME) has a digest of $(MQ_IMAGE_ADVANCEDSERVER_DIGEST)**"$(END)))
504+
@printf $(TITLE)"\nCopying $(MQ_IMAGE_FULL_RELEASE_NAME) image with digest $(MQ_IMAGE_ADVANCEDSERVER_DIGEST) to \"$(MQ_DELIVERY_REGISTRY_HOSTNAME)\"\n"$(END)
505+
docker run skopeo:latest copy --src-creds $(MQ_DELIVERY_REGISTRY_USER):$(MQ_DELIVERY_REGISTRY_CREDENTIAL) --dest-creds $(MQ_DELIVERY_REGISTRY_USER):$(MQ_DELIVERY_REGISTRY_CREDENTIAL) docker://$(MQ_BUILD_REGISTRY_PATH)/$(MQ_IMAGE_ADVANCEDSERVER)@$(MQ_IMAGE_ADVANCEDSERVER_DIGEST) docker://$(MQ_DELIVERY_REGISTRY_FULL_PATH)/$(MQ_IMAGE_FULL_RELEASE_NAME)
476506

477507
.PHONY: pull-advancedserver
478508
pull-advancedserver:
@@ -550,7 +580,7 @@ clean:
550580

551581
.PHONY: go-install
552582
go-install:
553-
GO_VERSION=$(GO_VERSION) ARCH=$(ARCH) ./go-install.sh
583+
ARCH=$(ARCH) ./travis-build-scripts/go-install.sh
554584

555585
.PHONY: install-build-deps
556586
install-build-deps:

travis-build-scripts/artifact-util.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ if [ "$DELETE_NAMESPACE" != "true" ]; then
128128
fi
129129
fi
130130

131-
REMOTE_PATH="https://${CACHE_PATH}/$TRAVIS_BUILD_ID"
131+
REMOTE_PATH="https://${CACHE_PATH}/$TRAVIS_BUILD_ID/"
132132

133133
if [ "$CHECK" == "true" ]; then
134134
printf "${GREENRIGHTARROW} Checking to see if file ${FILE_NAME} exists in repository ${REMOTE_PATH}\n"

travis-build-scripts/build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ if [ -z "$BUILD_INTERNAL_LEVEL" ] ; then
6262
echo 'Building Production image...' && echo -en 'travis_fold:start:build-advancedserver\\r'
6363
get_archive_level MQ_ARCHIVE_REPOSITORY
6464
make build-advancedserver
65+
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
66+
make push-advancedserver
67+
make push-devserver
68+
fi
6569
echo -en 'travis_fold:end:build-advancedserver\\r'
6670
fi
6771
fi
@@ -81,4 +85,4 @@ else
8185
make build-advancedserver
8286
echo -en 'travis_fold:end:build-advancedserver\\r'
8387
fi
84-
fi
88+
fi

travis-build-scripts/cleanup-cache.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
# limitations under the License.
1616

1717
echo 'Cleaning up remote cache' && echo -en 'travis_fold:start:cleanup\\r'
18-
./travis-build-scripts/artifact-util.sh -c ${CACHE_PATH} -u ${REPOSITORY_USER} -p ${REPOSITORY_CREDENTIAL} -f cache/${TAGCACHE_FILE} --delete
19-
echo -en 'travis_fold:end:cleanup\\r'
18+
./travis-build-scripts/artifact-util.sh -c ${CACHE_PATH} -u ${REPOSITORY_USER} -p ${REPOSITORY_CREDENTIAL} --delete-namespace
19+
echo -en 'travis_fold:end:cleanup\\r'

go-install.sh renamed to travis-build-scripts/go-install.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919

2020
set -ex
2121

22-
sudo rm -rf /usr/local/go;
22+
GO_VERSION="1.22.9"
23+
sudo rm -rf /usr/local/go
2324
DOWNLOAD_URL="https://go.dev/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz"
2425
curl -fLo go.tar.gz "${DOWNLOAD_URL}"
2526
sudo tar -C /usr/local -xzf go.tar.gz
26-
export PATH=$PATH:/usr/local/go/bin
27+
export PATH=/usr/local/go/bin:$PATH
2728
go version

travis-build-scripts/promote.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
# © Copyright IBM Corporation 2019, 2021
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
20+
echo "Not Promoting as we are a pull request"
21+
exit 0
22+
fi
23+
24+
if [ ! -z $2 ]; then
25+
export ARCH=$2
26+
fi
27+
28+
function promote_developer {
29+
echo 'Promoting Developer image...' && echo -en 'travis_fold:start:promote-devserver\\r'
30+
make promote-devserver
31+
echo -en 'travis_fold:end:promote-devserver\\r'
32+
}
33+
34+
function promote_production {
35+
echo 'Promoting Production image...' && echo -en 'travis_fold:start:promote-advancedserver\\r'
36+
make promote-advancedserver
37+
echo -en 'travis_fold:end:promote-advancedserver\\r'
38+
}
39+
40+
# call relevant promote function
41+
if [ ! -z $1 ]; then
42+
case "$1" in
43+
developer) promote_developer
44+
;;
45+
production) promote_production
46+
;;
47+
*) echo "ERROR: Type ( developer | production ) must be passed to promote.sh"
48+
exit 1
49+
;;
50+
esac
51+
else
52+
echo "ERROR: Type ( developer | production ) must be passed to promote.sh"
53+
exit 1
54+
fi

travis-build-scripts/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ if [ -z "$BUILD_INTERNAL_LEVEL" ] ; then
5959
printf '\nNot pushing or writing images to Artifactory because the stream is locked.\n'
6060
exit 0
6161
fi
62-
./travis-build-scripts/push.sh developer
63-
./travis-build-scripts/push.sh production
62+
./travis-build-scripts/promote.sh developer
63+
./travis-build-scripts/promote.sh production
6464
fi
6565
else
6666
if [[ "$BUILD_INTERNAL_LEVEL" == *".DE"* ]]; then

0 commit comments

Comments
 (0)