Compare commits

...

93 Commits

Author SHA1 Message Date
Sonatype 4c07c9c7cb Update Repository Manager to 3.24.1-01. 2020-06-11 16:30:22 +00:00
Sonatype 1f2c2c1c71 Update Repository Manager to 3.24.0-02. 2020-06-08 14:29:00 +00:00
Rich Seddon 073ebe2abb Added instructions for stopping
The default timeout for docker stop is too low, added note that more time is needed to ensure a clean shutdown.
2020-06-01 17:24:30 -05:00
Stuart McCulloch 038814766e Update heap defaults to match https://help.sonatype.com/repomanager3/installation/system-requirements#SystemRequirements-ExampleMaximumMemoryConfigurations (#122) 2020-05-21 22:56:25 +01:00
Sonatype 2b5432909c Update Repository Manager to 3.23.0-03. 2020-05-05 13:46:11 +00:00
John M Flinchbaugh b78891de50 INT-2562 resilience for red hat trigger (#119)
* INT-2562 retry while watching for build to finish
* INT-2562 allow skipping red hat
   for days when the service is really busted
2020-05-01 13:11:11 -04:00
John M Flinchbaugh 031802f651 cloud-ops email -> support (#118)
cloud-ops email didn't really exist.
2020-04-27 18:20:41 -04:00
Sonatype 5d77b34f8e Update Repository Manager to 3.22.1-02. 2020-04-16 15:08:58 +00:00
Joseph Cava e8207fcb25 Pull in PR #113 update labels - INT (#117)
* Update metadata for Dockerfile label - INT (#113)

* Update Repository Manager to 3.22.0-02. Update Repository Manager Cookbook to release-0.5.20190212-155606.d1afdfe.

Co-authored-by: Kevin Chung <kevin.chung@redhat.com>
Co-authored-by: Sonatype <sonatype-ci@sonatype.com>
2020-04-08 16:18:21 -07:00
Sonatype bfd3d1b270 Update Repository Manager to 3.22.0-02. 2020-03-27 21:14:35 +00:00
Sonatype 72534f2dd7 Update Repository Manager to 3.21.2-03. 2020-03-23 17:32:53 +00:00
John M Flinchbaugh f23c8b9311 Merge pull request #115 from sonatype/Red_Hat_Connect_To_UBI
INT-2561 automate RHCC build for NXRM
2020-03-11 14:19:17 -04:00
John Flinchbaugh dc4cf29b54 better description for skip parameter 2020-03-11 12:15:00 -04:00
John Flinchbaugh 180cb4562a allow skipping push 2020-03-11 11:58:49 -04:00
John Flinchbaugh d6b508c796 use params map for real boolean 2020-03-11 11:40:11 -04:00
John Flinchbaugh 1ba2e9f3dc fix param map 2020-03-11 11:13:22 -04:00
John Flinchbaugh 0692cbc886 provide parameter to force red hat build 2020-03-11 11:10:46 -04:00
John Flinchbaugh 65d6bc6ffc fields can be private now 2020-03-03 17:19:53 -05:00
John Flinchbaugh c40eba2ce2 more OO
* init the HttpBuilder in normal constructor
* no need to curry a tags function once everything is available on class
2020-03-03 17:06:16 -05:00
John Flinchbaugh f864f4af39 better messaging for timeout 2020-03-03 16:51:12 -05:00
John Flinchbaugh 98de4deeba 20-minute timeout waiting for build to complete 2020-03-03 16:46:31 -05:00
John Flinchbaugh f52d0fc751 no need to pass around projectId 2020-03-03 16:23:31 -05:00
John Flinchbaugh 6dee786433 wrap it all up in a class 2020-03-03 16:19:05 -05:00
John Flinchbaugh c05daa83c5 extract a function for requesting tags 2020-03-03 15:46:01 -05:00
John Flinchbaugh cd52f63332 exit status for jenkins to see 2020-03-03 14:49:23 -05:00
John Flinchbaugh cbe4eb9930 mv groovy script to ci/ dir 2020-03-03 12:33:47 -05:00
John Flinchbaugh 5645de78c5 javadocs 2020-03-03 12:31:31 -05:00
John Flinchbaugh 1a455fcb14 lose the extra post() 2020-03-03 12:24:11 -05:00
John Flinchbaugh a37ff8be28 reuse httpbuilder for less repetition 2020-03-03 12:13:48 -05:00
John Flinchbaugh 584d0c15ee document the usage from jenkins 2020-03-03 12:13:15 -05:00
John Flinchbaugh 7ba375367b no need for groovy strings 2020-03-02 18:30:04 -05:00
John Flinchbaugh 019192a2cd copyright header on script 2020-03-02 17:58:24 -05:00
John Flinchbaugh 48a8fb6edd trigger build with redhat service calls 2020-03-02 17:55:11 -05:00
John Flinchbaugh 50050c2f18 trigger the red hat build service 2020-02-27 17:03:48 -05:00
John Flinchbaugh 585e06eebc have jenkins update the new ubi file 2020-02-26 16:53:11 -05:00
John Flinchbaugh d40910f2dc Merge branch 'master' into Red_Hat_Connect_To_UBI 2020-02-26 14:50:16 -05:00
John Flinchbaugh 0c660de07d doc multiple images that can be built 2020-02-26 14:31:57 -05:00
John Flinchbaugh fece22c414 bring back the master dockerfiles
when we merge to master, we'll want to keep these
2020-02-26 12:29:46 -05:00
John Flinchbaugh 3845c0ef59 upgrade to latest 3.21.1-01 release 2020-02-26 11:54:07 -05:00
Sonatype a90e1c8214 Update Repository Manager to 3.21.1-01. 2020-02-19 03:46:56 +00:00
Sonatype 8f40d76fea Update Repository Manager to 3.21.0-05. 2020-02-18 19:31:08 +00:00
Justin Young 16792220a2 Update Repository Manager to 3.20.1-01. 2020-01-22 17:04:58 -08:00
Sonatype 7cd4c3638e Update Repository Manager to 3.20.1-01. 2019-12-20 15:58:53 +00:00
Sonatype fc2884a7ec Update Repository Manager to 3.20.0-04. 2019-12-13 11:26:16 +00:00
Sonatype f128f2f55e Update Repository Manager to 3.19.1-01. 2019-10-09 16:17:45 +00:00
Sonatype 450f668946 Update Repository Manager to 3.19.0-01. 2019-09-30 17:44:08 +00:00
Justin Young 705193f62d Remove rebuild db 2019-09-06 10:46:09 -07:00
Justin Young 277031316b Red Hat Connect to UBI 2019-09-06 10:34:07 -07:00
Sonatype 3e44657f5e Update Repository Manager to 3.18.1-01. 2019-08-09 15:47:12 +00:00
Adam Boesch 37a9fcd2b9 NEXUS-20366 - Use UBI8 instead of CentOS (#111) 2019-07-26 15:31:49 -04:00
Sonatype 0f4ff59f0b Update Repository Manager to 3.18.0-01. 2019-07-26 17:15:07 +00:00
Rich Seddon a1f0ab750d Update README.md
Added a note that our system requirements should be taken into account when provisioning the docker container.
2019-07-12 15:10:43 -05:00
Sonatype 907d39d806 Update Repository Manager to 3.17.0-01. 2019-06-24 20:33:45 +00:00
Matthew Piggott bd57ceec2a Remove references to old default password 2019-06-17 14:05:47 -04:00
Joe Tom a318fa893c trivial clarify 2019-06-13 11:32:47 -04:00
Sonatype 706e45b5b0 Update Repository Manager to 3.16.2-01. 2019-05-31 20:04:22 +00:00
Matthew Piggott 54894fcec3 Specify chef version 14.12.9 (#109) 2019-05-31 16:01:08 -04:00
Sonatype 451c0c1c36 Update Repository Manager to 3.16.1-02. 2019-04-16 19:41:08 +00:00
Sonatype d180fb611d Update Repository Manager to 3.16.0-01. 2019-04-11 19:36:18 +00:00
bigspotteddog c770722970 Use openjdk. 2019-02-12 17:49:11 -08:00
Sonatype c75f2c4c2a Update Repository Manager to 3.15.2-01. Update Repository Manager Cookbook to release-0.5.20190212-155606.d1afdfe. 2019-02-13 01:21:48 +00:00
Sonatype 318f53548b Update Repository Manager to 3.15.2-01. 2019-01-29 12:52:08 +00:00
Dawid Sawa 7f8dca3509 Switchover to OpenJDK (#105) 2019-01-28 11:46:03 +00:00
Sonatype cad92467b0 Update Repository Manager to 3.15.1-01. Update Oracle JRE to 8u202-b08. 2019-01-18 05:39:05 +00:00
Sonatype f52169d41c Update Repository Manager to 3.15.0-01. 2019-01-14 16:51:37 +00:00
Sonatype 11cff03638 Update Repository Manager Cookbook to release-0.5.20180828-231916.863899c. Update Oracle JRE to 8u192-b12. 2018-10-16 22:13:42 +00:00
Sonatype 13a8d3d22f Update Repository Manager to 3.14.0-04. 2018-10-12 16:41:34 +00:00
Sonatype 78867e3c6c Update Repository Manager Cookbook to release-0.5.20180828-161555.3c23098. 2018-08-28 23:32:49 +00:00
Sonatype 0e272c92e1 Update Repository Manager to 3.13.0-01. 2018-07-19 19:24:48 +00:00
Sonatype ce488a2cbd Update Repository Manager Cookbook to release-0.5.20180717-185554.2346ca8. Update Oracle JRE to 8u181-b13. 2018-07-17 19:05:29 +00:00
Sonatype 6a1cc21a6e Update Repository Manager to 3.12.1-01. 2018-06-11 13:22:32 +00:00
Sonatype 850d5a247e Update Repository Manager Cookbook to release-0.5.20180420-205540.75aa3de. 2018-05-29 22:18:48 +00:00
Justin Young a614458159 CI Pipeline Library (#103) 2018-05-29 15:16:46 -07:00
Sonatype 3a68297242 Update Repository Manager to 3.12.0-01. 2018-05-22 21:38:51 +00:00
Sonatype 5f926027a5 Update Repository Manager to 3.11.0-01. 2018-05-01 19:43:30 +00:00
Justin Young af1f6b460c Update JRE Url from Jenkins Parameter (#101)
* Update JRE Url from Jenkins parameter.

* Adjust Jenkins stage name to be more descriptive.

* Update JRE Url from Jenkins test (#102)

* Update Oracle JRE to 8u172-b11.
2018-04-20 14:57:11 -07:00
Sonatype 7083c277f3 Update Repository Manager to 3.10.0-04. Update Repository Manager Cookbook to release-0.5.20180307-101842.bde3aae. 2018-04-05 15:11:19 +00:00
Justin Young a6d18f36fc Documentation on pulling Red Hat certified image from the Red Hat Container Catalog. 2018-03-22 16:12:16 -07:00
Justin Young 4c730ede7e Documentation fix regarding the persistence of a docker volume. 2018-03-22 13:59:47 -07:00
Justin Young 005381cc14 When updating version from master, use short version for tag. 2018-03-08 10:48:40 -08:00
Joe Tom eee4bcdbf6 Fixes
* I made the link direct because it was 403ing on https://hub.docker.com/r/sonatype/nexus3/#running with the partial link.
* While here noticed a typo fix, fixed that too.
2018-03-07 10:34:12 -05:00
Sonatype 26c8c44a72 Update Repository Manager to 3.9.0-01. 2018-03-01 00:21:56 +00:00
Justin Young 042408ae64 When automating version updates, ensure tags to GH and DH use latest version. 2018-02-14 13:43:05 -08:00
Joseph Cava fe501881ed Update Repository Manager to 3.8.0-02 - INT-447 (#99)
* Update Repository Manager to 3.8.0-02

* Update Repository Manager Cookbook to release-0.5.20180205-125532.9212679
2018-02-05 14:53:46 -08:00
Brad Beck af463afcd8 Update Java 8u162 (#97) 2018-02-05 16:23:57 -06:00
Justin Young c5a275d3e6 Add more details in README regarding Red Hat images. 2018-01-11 17:25:30 -08:00
Justin Young 7411a0c123 Red Hat Certified Image - INT-414 (#91)
* Red Hat Certified Image

* Jenkins updates for all RH templates. CentOS template

* Update chef versions to latest release.

* Add description label to Red Hat offerings.
2018-01-10 17:04:44 -08:00
Justin Young d9a13bd2e6 Use ENV for Branch Name (#94)
* Use checkout object to determine git details.

* Normalize origin/master to master.
2018-01-02 13:35:01 -08:00
Sonatype 78fed87f0b Update Repository Manager to 3.7.1-02. 2017-12-29 15:53:22 +00:00
Joseph Cava 4f2383143f INT - Automate Version Update (#92) 2017-12-29 22:35:40 +07:00
Joseph Cava 7c3aa6d946 Update Repository Manager to 3.7.0-04 (#93)
* Update Repository Manager to 3.7.0-04.
* Update Repository Manager Cookbook to release-0.5.20171219-161323.cc1040a.
2017-12-19 18:12:46 -06:00
Andrew Taylor 1fdaf18624 Bumped release to 3.6.2. (#90) 2017-11-29 14:37:11 -08:00
Justin Young 7611c5315f Remove LoadAsOSS - INT-406 (#89) 2017-11-28 16:31:29 -08:00
9 changed files with 641 additions and 91 deletions
+1
View File
@@ -28,6 +28,7 @@ Sonatype internal people:
* [@jeviolle](https://github.com/jeviolle/) (Rick Briganti/The Money)
* [@jswank](https://github.com/jswank/) (Jason Swank)
* [@DarthHater](https://github.com/darthhater/) (Jeffry Hesse)
* [@dawidsawa](https://github.com/dawidsawa/) (Dawid Sawa)
External contributors:
+32 -22
View File
@@ -12,57 +12,67 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM centos:centos7
FROM registry.access.redhat.com/ubi8/ubi
MAINTAINER Sonatype <cloud-ops@sonatype.com>
LABEL vendor=Sonatype \
LABEL name="Nexus Repository Manager" \
maintainer="Sonatype <support@sonatype.com>" \
vendor=Sonatype \
version="3.24.1-01" \
release="3.24.1" \
url="https://sonatype.com" \
summary="The Nexus Repository Manager server \
with universal support for popular component formats." \
description="The Nexus Repository Manager server \
with universal support for popular component formats." \
run="docker run -d --name NAME \
-p 8081:8081 \
IMAGE" \
stop="docker stop NAME" \
com.sonatype.license="Apache License, Version 2.0" \
com.sonatype.name="Nexus Repository Manager base image"
com.sonatype.name="Nexus Repository Manager base image" \
io.k8s.description="The Nexus Repository Manager server \
with universal support for popular component formats." \
io.k8s.display-name="Nexus Repository Manager" \
io.openshift.expose-services="8081:8081" \
io.openshift.tags="Sonatype,Nexus,Repository Manager"
ARG NEXUS_VERSION=3.6.1-02
ARG NEXUS_VERSION=3.24.1-01
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz
ARG NEXUS_DOWNLOAD_SHA256_HASH=4a658996cf29ca2d4f9c8b3d3cff11bfc358d88f03495812d7814268f0b1259b
ENV JAVA_HOME=/opt/java \
JAVA_VERSION_MAJOR=8 \
JAVA_VERSION_MINOR=152 \
JAVA_VERSION_BUILD=16 \
JAVA_DOWNLOAD_HASH=aa0333dd3019491ca4f6ddbe78cdb6d0
ENV JAVA_URL=http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_DOWNLOAD_HASH}/server-jre-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz \
JAVA_DOWNLOAD_SHA256_HASH=e8a341ce566f32c3d06f6d0f0eeea9a0f434f538d22af949ae58bc86f2eeaae4
ARG NEXUS_DOWNLOAD_SHA256_HASH=4034ceaca2633124fd49ecfec8dd73367bd94a308595fd864ab461a86284a9f8
# configure nexus runtime
ENV SONATYPE_DIR=/opt/sonatype
ENV NEXUS_HOME=${SONATYPE_DIR}/nexus \
NEXUS_DATA=/nexus-data \
NEXUS_CONTEXT='' \
SONATYPE_WORK=${SONATYPE_DIR}/sonatype-work
SONATYPE_WORK=${SONATYPE_DIR}/sonatype-work \
DOCKER_TYPE='rh-docker'
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION="release-0.5.20171115-163526.03915d6"
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION="release-0.5.20190212-155606.d1afdfe"
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL="https://github.com/sonatype/chef-nexus-repository-manager/releases/download/${NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION}/chef-nexus-repository-manager.tar.gz"
ADD solo.json.erb /var/chef/solo.json.erb
# Install using chef-solo
RUN curl -L https://www.getchef.com/chef/install.sh | bash \
# Chef version locked to avoid needing to accept the EULA on behalf of whomever builds the image
RUN yum install -y --disableplugin=subscription-manager hostname procps \
&& curl -L https://www.getchef.com/chef/install.sh | bash -s -- -v 14.12.9 \
&& /opt/chef/embedded/bin/erb /var/chef/solo.json.erb > /var/chef/solo.json \
&& chef-solo \
--recipe-url ${NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL} \
--json-attributes /var/chef/solo.json \
&& rpm -qa *chef* | xargs rpm -e \
&& rpm --rebuilddb \
&& rm -rf /etc/chef \
&& rm -rf /opt/chefdk \
&& rm -rf /var/cache/yum \
&& rm -rf /var/chef
&& rm -rf /var/chef \
&& yum clean all
VOLUME ${NEXUS_DATA}
EXPOSE 8081
USER nexus
ENV INSTALL4J_ADD_VM_PARAMS="-Xms1200m -Xmx1200m -XX:MaxDirectMemorySize=2g -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs"
ENV INSTALL4J_ADD_VM_PARAMS="-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs"
CMD ["sh", "-c", "${SONATYPE_DIR}/start-nexus-repository-manager.sh"]
+78
View File
@@ -0,0 +1,78 @@
# Copyright (c) 2016-present Sonatype, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM centos:centos7
LABEL name="Nexus Repository Manager" \
maintainer="Sonatype <support@sonatype.com>" \
vendor=Sonatype \
version="3.24.1-01" \
release="3.24.1" \
url="https://sonatype.com" \
summary="The Nexus Repository Manager server \
with universal support for popular component formats." \
description="The Nexus Repository Manager server \
with universal support for popular component formats." \
run="docker run -d --name NAME \
-p 8081:8081 \
IMAGE" \
stop="docker stop NAME" \
com.sonatype.license="Apache License, Version 2.0" \
com.sonatype.name="Nexus Repository Manager base image" \
io.k8s.description="The Nexus Repository Manager server \
with universal support for popular component formats." \
io.k8s.display-name="Nexus Repository Manager" \
io.openshift.expose-services="8081:8081" \
io.openshift.tags="Sonatype,Nexus,Repository Manager"
ARG NEXUS_VERSION=3.24.1-01
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz
ARG NEXUS_DOWNLOAD_SHA256_HASH=4034ceaca2633124fd49ecfec8dd73367bd94a308595fd864ab461a86284a9f8
# configure nexus runtime
ENV SONATYPE_DIR=/opt/sonatype
ENV NEXUS_HOME=${SONATYPE_DIR}/nexus \
NEXUS_DATA=/nexus-data \
NEXUS_CONTEXT='' \
SONATYPE_WORK=${SONATYPE_DIR}/sonatype-work \
DOCKER_TYPE='rh-docker'
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION="release-0.5.20190212-155606.d1afdfe"
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL="https://github.com/sonatype/chef-nexus-repository-manager/releases/download/${NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION}/chef-nexus-repository-manager.tar.gz"
ADD solo.json.erb /var/chef/solo.json.erb
# Install using chef-solo
RUN curl -L https://www.getchef.com/chef/install.sh | bash \
&& /opt/chef/embedded/bin/erb /var/chef/solo.json.erb > /var/chef/solo.json \
&& chef-solo \
--node_name nexus_repository_red_hat_docker_build \
--recipe-url ${NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL} \
--json-attributes /var/chef/solo.json \
&& rpm -qa *chef* | xargs rpm -e \
&& rpm --rebuilddb \
&& rm -rf /etc/chef \
&& rm -rf /opt/chefdk \
&& rm -rf /var/cache/yum \
&& rm -rf /var/chef
VOLUME ${NEXUS_DATA}
EXPOSE 8081
USER nexus
ENV INSTALL4J_ADD_VM_PARAMS="-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs"
ENTRYPOINT ["/uid_entrypoint.sh"]
CMD ["sh", "-c", "${SONATYPE_DIR}/start-nexus-repository-manager.sh"]
+78
View File
@@ -0,0 +1,78 @@
# Copyright (c) 2016-present Sonatype, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM registry.access.redhat.com/rhel7/rhel
LABEL name="Nexus Repository Manager" \
maintainer="Sonatype <support@sonatype.com>" \
vendor=Sonatype \
version="3.24.1-01" \
release="3.24.1" \
url="https://sonatype.com" \
summary="The Nexus Repository Manager server \
with universal support for popular component formats." \
description="The Nexus Repository Manager server \
with universal support for popular component formats." \
run="docker run -d --name NAME \
-p 8081:8081 \
IMAGE" \
stop="docker stop NAME" \
com.sonatype.license="Apache License, Version 2.0" \
com.sonatype.name="Nexus Repository Manager base image" \
io.k8s.description="The Nexus Repository Manager server \
with universal support for popular component formats." \
io.k8s.display-name="Nexus Repository Manager" \
io.openshift.expose-services="8081:8081" \
io.openshift.tags="Sonatype,Nexus,Repository Manager"
ARG NEXUS_VERSION=3.24.1-01
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz
ARG NEXUS_DOWNLOAD_SHA256_HASH=4034ceaca2633124fd49ecfec8dd73367bd94a308595fd864ab461a86284a9f8
# configure nexus runtime
ENV SONATYPE_DIR=/opt/sonatype
ENV NEXUS_HOME=${SONATYPE_DIR}/nexus \
NEXUS_DATA=/nexus-data \
NEXUS_CONTEXT='' \
SONATYPE_WORK=${SONATYPE_DIR}/sonatype-work \
DOCKER_TYPE='rh-docker'
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION="release-0.5.20190212-155606.d1afdfe"
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL="https://github.com/sonatype/chef-nexus-repository-manager/releases/download/${NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION}/chef-nexus-repository-manager.tar.gz"
ADD solo.json.erb /var/chef/solo.json.erb
# Install using chef-solo
RUN curl -L https://www.getchef.com/chef/install.sh | bash \
&& /opt/chef/embedded/bin/erb /var/chef/solo.json.erb > /var/chef/solo.json \
&& chef-solo \
--node_name nexus_repository_red_hat_docker_build \
--recipe-url ${NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL} \
--json-attributes /var/chef/solo.json \
&& rpm -qa *chef* | xargs rpm -e \
&& rpm --rebuilddb \
&& rm -rf /etc/chef \
&& rm -rf /opt/chefdk \
&& rm -rf /var/cache/yum \
&& rm -rf /var/chef
VOLUME ${NEXUS_DATA}
EXPOSE 8081
USER nexus
ENV INSTALL4J_ADD_VM_PARAMS="-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs"
ENTRYPOINT ["/uid_entrypoint.sh"]
CMD ["sh", "-c", "${SONATYPE_DIR}/start-nexus-repository-manager.sh"]
+79
View File
@@ -0,0 +1,79 @@
# Copyright (c) 2016-present Sonatype, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM registry.access.redhat.com/ubi8/ubi
LABEL name="Nexus Repository Manager" \
vendor=Sonatype \
maintainer="Sonatype <support@sonatype.com>" \
version="3.24.1-01" \
release="3.24.1" \
url="https://sonatype.com" \
summary="The Nexus Repository Manager server \
with universal support for popular component formats." \
description="The Nexus Repository Manager server \
with universal support for popular component formats." \
run="docker run -d --name NAME \
-p 8081:8081 \
IMAGE" \
stop="docker stop NAME" \
com.sonatype.license="Apache License, Version 2.0" \
com.sonatype.name="Nexus Repository Manager base image" \
io.k8s.description="The Nexus Repository Manager server \
with universal support for popular component formats." \
io.k8s.display-name="Nexus Repository Manager" \
io.openshift.expose-services="8081:8081" \
io.openshift.tags="Sonatype,Nexus,Repository Manager"
ARG NEXUS_VERSION=3.24.1-01
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz
ARG NEXUS_DOWNLOAD_SHA256_HASH=4034ceaca2633124fd49ecfec8dd73367bd94a308595fd864ab461a86284a9f8
# configure nexus runtime
ENV SONATYPE_DIR=/opt/sonatype
ENV NEXUS_HOME=${SONATYPE_DIR}/nexus \
NEXUS_DATA=/nexus-data \
NEXUS_CONTEXT='' \
SONATYPE_WORK=${SONATYPE_DIR}/sonatype-work \
DOCKER_TYPE='rh-docker'
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION="release-0.5.20190212-155606.d1afdfe"
ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL="https://github.com/sonatype/chef-nexus-repository-manager/releases/download/${NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION}/chef-nexus-repository-manager.tar.gz"
ADD solo.json.erb /var/chef/solo.json.erb
# Install using chef-solo
# Chef version locked to avoid needing to accept the EULA on behalf of whomever builds the image
RUN curl -L https://www.getchef.com/chef/install.sh | bash -s -- -v 14.12.9 \
&& /opt/chef/embedded/bin/erb /var/chef/solo.json.erb > /var/chef/solo.json \
&& chef-solo \
--node_name nexus_repository_red_hat_docker_build \
--recipe-url ${NEXUS_REPOSITORY_MANAGER_COOKBOOK_URL} \
--json-attributes /var/chef/solo.json \
&& rpm -qa *chef* | xargs rpm -e \
&& rm -rf /etc/chef \
&& rm -rf /opt/chefdk \
&& rm -rf /var/cache/yum \
&& rm -rf /var/chef \
&& yum clean all
VOLUME ${NEXUS_DATA}
EXPOSE 8081
USER nexus
ENV INSTALL4J_ADD_VM_PARAMS="-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs"
ENTRYPOINT ["/uid_entrypoint.sh"]
CMD ["sh", "-c", "${SONATYPE_DIR}/start-nexus-repository-manager.sh"]
Vendored
+144 -46
View File
@@ -3,14 +3,25 @@
* Includes the third-party code listed at http://links.sonatype.com/products/nexus/attributions.
* "Sonatype" is a trademark of Sonatype, Inc.
*/
@Library('zion-pipeline-library')
@Library('ci-pipeline-library') _
import com.sonatype.jenkins.pipeline.GitHub
import com.sonatype.jenkins.pipeline.OsTools
properties([
parameters([
string(defaultValue: '', description: 'New Nexus Repository Manager Version', name: 'nexus_repository_manager_version'),
string(defaultValue: '', description: 'New Nexus Repository Manager Version Sha256', name: 'nexus_repository_manager_version_sha'),
string(defaultValue: '', description: 'New Nexus Repository Manager Cookbook Version', name: 'nexus_repository_manager_cookbook_version'),
booleanParam(defaultValue: false, description: 'Skip Pushing of Docker Image and Tags', name: 'skip_push'),
booleanParam(defaultValue: false, description: 'Force Red Hat Certified Build for a non-master branch', name: 'force_red_hat_build'),
booleanParam(defaultValue: false, description: 'Skip Red Hat Certified Build', name: 'skip_red_hat_build'),
])
])
node('ubuntu-zion') {
def commitId, commitDate, version, imageId
def commitId, commitDate, version, imageId, branch, dockerFileLocations
def organization = 'sonatype',
repository = 'docker-nexus3',
gitHubRepository = 'docker-nexus3',
credentialsId = 'integrations-github-api',
imageName = 'sonatype/nexus3',
archiveName = 'docker-nexus3',
@@ -22,11 +33,22 @@ node('ubuntu-zion') {
deleteDir()
OsTools.runSafe(this, "docker system prune -a -f")
checkout scm
def checkoutDetails = checkout scm
commitId = OsTools.runSafe(this, 'git rev-parse HEAD')
dockerFileLocations = [
"${pwd()}/Dockerfile",
"${pwd()}/Dockerfile.rh.centos",
"${pwd()}/Dockerfile.rh.el",
"${pwd()}/Dockerfile.rh.ubi"
]
branch = checkoutDetails.GIT_BRANCH == 'origin/master' ? 'master' : checkoutDetails.GIT_BRANCH
commitId = checkoutDetails.GIT_COMMIT
commitDate = OsTools.runSafe(this, "git show -s --format=%cd --date=format:%Y%m%d-%H%M%S ${commitId}")
OsTools.runSafe(this, 'git config --global user.email sonatype-ci@sonatype.com')
OsTools.runSafe(this, 'git config --global user.name Sonatype CI')
version = readVersion()
def apiToken
@@ -34,7 +56,21 @@ node('ubuntu-zion') {
usernameVariable: 'GITHUB_API_USERNAME', passwordVariable: 'GITHUB_API_PASSWORD']]) {
apiToken = env.GITHUB_API_PASSWORD
}
gitHub = new GitHub(this, "${organization}/${repository}", apiToken)
gitHub = new GitHub(this, "${organization}/${gitHubRepository}", apiToken)
if (params.nexus_repository_manager_version && params.nexus_repository_manager_version_sha) {
stage('Update Repository Manager Version') {
OsTools.runSafe(this, "git checkout ${branch}")
dockerFileLocations.each { updateRepositoryManagerVersion(it) }
version = getShortVersion(params.nexus_repository_manager_version)
}
}
if (params.nexus_repository_manager_cookbook_version) {
stage('Update Repository Manager Cookbook Version') {
OsTools.runSafe(this, "git checkout ${branch}")
dockerFileLocations.each { updateRepositoryCookbookVersion(it) }
}
}
}
stage('Build') {
gitHub.statusUpdate commitId, 'pending', 'build', 'Build is running'
@@ -70,56 +106,84 @@ node('ubuntu-zion') {
if (currentBuild.result == 'FAILURE') {
return
}
if (params.nexus_repository_manager_version && params.nexus_repository_manager_version_sha
|| params.nexus_repository_manager_cookbook_version) {
stage('Commit Automated Code Update') {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'integrations-github-api',
usernameVariable: 'GITHUB_API_USERNAME', passwordVariable: 'GITHUB_API_PASSWORD']]) {
def commitMessage = [
params.nexus_repository_manager_version && params.nexus_repository_manager_version_sha ?
"Update Repository Manager to ${params.nexus_repository_manager_version}." : "",
params.nexus_repository_manager_cookbook_version ?
"Update Repository Manager Cookbook to ${params.nexus_repository_manager_cookbook_version}." : ""
].findAll({ it }).join(' ')
OsTools.runSafe(this, """
git add .
git commit -m '${commitMessage}'
git push https://${env.GITHUB_API_USERNAME}:${env.GITHUB_API_PASSWORD}@github.com/${organization}/${gitHubRepository}.git ${branch}
""")
}
}
}
stage('Archive') {
dir('build/target') {
OsTools.runSafe(this, "docker save ${imageName} | gzip > ${archiveName}.tar.gz")
archiveArtifacts artifacts: "${archiveName}.tar.gz", onlyIfSuccessful: true
}
}
if (scm.branches[0].name != '*/master') {
return
}
input 'Push image and tags?'
stage('Push image') {
def dockerhubApiToken
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'docker-hub-credentials',
usernameVariable: 'DOCKERHUB_API_USERNAME', passwordVariable: 'DOCKERHUB_API_PASSWORD']]) {
OsTools.runSafe(this, "docker tag ${imageId} ${organization}/${dockerHubRepository}:${version}")
OsTools.runSafe(this, "docker tag ${imageId} ${organization}/${dockerHubRepository}:latest")
OsTools.runSafe(this, """
docker login --username ${env.DOCKERHUB_API_USERNAME} --password ${env.DOCKERHUB_API_PASSWORD}
""")
OsTools.runSafe(this, "docker push ${organization}/${dockerHubRepository}")
if (branch == 'master' && ! params.skip_push) {
input 'Push image and tags?'
stage('Push image') {
def dockerhubApiToken
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'docker-hub-credentials',
usernameVariable: 'DOCKERHUB_API_USERNAME', passwordVariable: 'DOCKERHUB_API_PASSWORD']]) {
OsTools.runSafe(this, "docker tag ${imageId} ${organization}/${dockerHubRepository}:${version}")
OsTools.runSafe(this, "docker tag ${imageId} ${organization}/${dockerHubRepository}:latest")
OsTools.runSafe(this, """
docker login --username ${env.DOCKERHUB_API_USERNAME} --password ${env.DOCKERHUB_API_PASSWORD}
""")
OsTools.runSafe(this, "docker push ${organization}/${dockerHubRepository}")
response = OsTools.runSafe(this, """
curl -X POST https://hub.docker.com/v2/users/login/ \
-H 'cache-control: no-cache' -H 'content-type: application/json' \
-d '{ "username": "${env.DOCKERHUB_API_USERNAME}", "password": "${env.DOCKERHUB_API_PASSWORD}" }'
""")
token = readJSON text: response
dockerhubApiToken = token.token
response = OsTools.runSafe(this, """
curl -X POST https://hub.docker.com/v2/users/login/ \
-H 'cache-control: no-cache' -H 'content-type: application/json' \
-d '{ "username": "${env.DOCKERHUB_API_USERNAME}", "password": "${env.DOCKERHUB_API_PASSWORD}" }'
""")
token = readJSON text: response
dockerhubApiToken = token.token
def readme = readFile file: 'README.md', encoding: 'UTF-8'
readme = readme.replaceAll("(?s)<!--.*?-->", "")
readme = readme.replace("\"", "\\\"")
readme = readme.replace("\n", "\\n")
response = httpRequest customHeaders: [[name: 'authorization', value: "JWT ${dockerhubApiToken}"]],
acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', httpMode: 'PATCH',
requestBody: "{ \"full_description\": \"${readme}\" }",
url: "https://hub.docker.com/v2/repositories/${organization}/${dockerHubRepository}/"
def readme = readFile file: 'README.md', encoding: 'UTF-8'
readme = readme.replaceAll("(?s)<!--.*?-->", "")
readme = readme.replace("\"", "\\\"")
readme = readme.replace("\n", "\\n")
response = httpRequest customHeaders: [[name: 'authorization', value: "JWT ${dockerhubApiToken}"]],
acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', httpMode: 'PATCH',
requestBody: "{ \"full_description\": \"${readme}\" }",
url: "https://hub.docker.com/v2/repositories/${organization}/${dockerHubRepository}/"
}
}
stage('Push tags') {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: credentialsId,
usernameVariable: 'GITHUB_API_USERNAME', passwordVariable: 'GITHUB_API_PASSWORD']]) {
OsTools.runSafe(this, "git tag ${version}")
OsTools.runSafe(this, """
git push \
https://${env.GITHUB_API_USERNAME}:${env.GITHUB_API_PASSWORD}@github.com/${organization}/${gitHubRepository}.git \
${version}
""")
}
OsTools.runSafe(this, "git tag -d ${version}")
}
}
stage('Push tags') {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: credentialsId,
usernameVariable: 'GITHUB_API_USERNAME', passwordVariable: 'GITHUB_API_PASSWORD']]) {
OsTools.runSafe(this, "git tag ${version}")
OsTools.runSafe(this, """
git push \
https://${env.GITHUB_API_USERNAME}:${env.GITHUB_API_PASSWORD}@github.com/${organization}/${repository}.git \
${version}
""")
if ((! params.skip_red_hat_build) && (branch == 'master' || params.force_red_hat_build)) {
stage('Trigger Red Hat Certified Image Build') {
withCredentials([
string(credentialsId: 'docker-nexus3-rh-build-project-id', variable: 'PROJECT_ID'),
string(credentialsId: 'rh-build-service-api-key', variable: 'API_KEY')]) {
final redHatVersion = "${version}-ubi"
runGroovy('ci/TriggerRedHatBuild.groovy', [redHatVersion, PROJECT_ID, API_KEY].join(' '))
}
}
OsTools.runSafe(this, "git tag -d ${version}")
}
} finally {
OsTools.runSafe(this, "docker logout")
@@ -127,15 +191,21 @@ node('ubuntu-zion') {
OsTools.runSafe(this, 'git clean -f && git reset --hard origin/master')
}
}
def readVersion() {
def content = readFile 'Dockerfile'
for (line in content.split('\n')) {
if (line.startsWith('ARG NEXUS_VERSION=')) {
return line.substring(18).split('-')[0]
return getShortVersion(line.substring(18))
}
}
error 'Could not determine version.'
}
def getShortVersion(version) {
return version.split('-')[0]
}
def getGemInstallDirectory() {
def content = OsTools.runSafe(this, "gem env")
for (line in content.split('\n')) {
@@ -145,3 +215,31 @@ def getGemInstallDirectory() {
}
error 'Could not determine user gem install directory.'
}
def updateRepositoryManagerVersion(dockerFileLocation) {
def dockerFile = readFile(file: dockerFileLocation)
def metaVersionRegex = /(version=")(\d\.\d{1,3}\.\d\-\d{2})(" \\)/
def metaShortVersionRegex = /(release=")(\d\.\d{1,3}\.\d)(" \\)/
def versionRegex = /(ARG NEXUS_VERSION=)(\d\.\d{1,3}\.\d\-\d{2})/
def shaRegex = /(ARG NEXUS_DOWNLOAD_SHA256_HASH=)([A-Fa-f0-9]{64})/
dockerFile = dockerFile.replaceAll(metaVersionRegex, "\$1${params.nexus_repository_manager_version}\$3")
dockerFile = dockerFile.replaceAll(metaShortVersionRegex,
"\$1${params.nexus_repository_manager_version.substring(0, params.nexus_repository_manager_version.indexOf('-'))}\$3")
dockerFile = dockerFile.replaceAll(versionRegex, "\$1${params.nexus_repository_manager_version}")
dockerFile = dockerFile.replaceAll(shaRegex, "\$1${params.nexus_repository_manager_version_sha}")
writeFile(file: dockerFileLocation, text: dockerFile)
}
def updateRepositoryCookbookVersion(dockerFileLocation) {
def dockerFile = readFile(file: dockerFileLocation)
def cookbookVersionRegex = /(ARG NEXUS_REPOSITORY_MANAGER_COOKBOOK_VERSION=")(release-\d\.\d\.\d{8}\-\d{6}\.[a-z0-9]{7})(")/
dockerFile = dockerFile.replaceAll(cookbookVersionRegex, "\$1${params.nexus_repository_manager_cookbook_version}\$3")
writeFile(file: dockerFileLocation, text: dockerFile)
}
+33 -8
View File
@@ -20,34 +20,42 @@
[![Join the chat at https://gitter.im/sonatype/nexus-developers](https://badges.gitter.im/sonatype/nexus-developers.svg)](https://gitter.im/sonatype/nexus-developers?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
A Dockerfile for Sonatype Nexus Repository Manager 3, based on CentOS.
A Dockerfile for Sonatype Nexus Repository Manager 3, starting with 3.18 the image is based on the [Red Hat Universal Base Image](https://www.redhat.com/en/blog/introducing-red-hat-universal-base-image) while earlier versions used CentOS.
* [Contribution Guidlines](#contribution-guidelines)
* [Running](#running)
* [Building the Nexus Repository Manager image](#building-the-nexus-repository-manager-image)
* [Chef Solo for Runtime and Application](#chef-solo-for-runtime-and-application)
* [Testing the Dockerfile](#testing-the-dockerfile)
* [Red Hat Certified Image](#red-hat-certified-image)
* [Notes](#notes)
* [Persistent Data](#persistent-data)
* [Getting Help](#getting-help)
## Contribution Guidelines
Go read [our contribution guidelines](/.github/CONTRIBUTING.md) to get a bit more familiar with how
Go read [our contribution guidelines](https://github.com/sonatype/docker-nexus3/blob/master/.github/CONTRIBUTING.md) to get a bit more familiar with how
we would like things to flow.
## Running
To run, binding the exposed port 8081 to the host.
To run, binding the exposed port 8081 to the host, use:
```
$ docker run -d -p 8081:8081 --name nexus sonatype/nexus3
```
When stopping, be sure to allow sufficient time for the databases to fully shut down.
```
docker stop --time=120 <CONTAINER_NAME>
```
To test:
```
$ curl -u admin:admin123 http://localhost:8081/service/metrics/ping
$ curl http://localhost:8081/
```
## Building the Nexus Repository Manager image
@@ -78,9 +86,27 @@ We are using `rspec` as the test framework. `serverspec` provides a docker backe
rspec [--backtrace] spec/Dockerfile_spec.rb
## Red Hat Certified Image
A Red Hat certified container image can be created using `Dockerfile.rh.ubi` which is built to be compliant with Red Hat certification.
The image includes additional meta data to comform with Kubernetes and OpenShift standards, a directory with the
licenses applicable to the software and a man file for help on how to use the software. It also uses an ENTRYPOINT
script the ensure the running user has access to the appropriate permissions for OpenShift 'restricted' SCC.
The Red Hat certified container image is available from the
[Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.connect.redhat.com/sonatype/nexus-repository-manager)
and qualified accounts can pull it from registry.connect.redhat.com.
## Other Red Hat Images
In addition to the Universal Base Image, we can build images based on:
* Red Hat Enterprise Linux: `Dockerfile.rh.el`
* CentOS: `Dockerfile.rh.centos`
## Notes
* Default credentials are: `admin` / `admin123`
* Our [system requirements](https://help.sonatype.com/display/NXRM3/System+Requirements) should be taken into account when provisioning the Docker container.
* Default user is `admin` and the uniquely generated password can be found in the `admin.password` file inside the volume. See [Persistent Data](#user-content-persistent-data) for information about the volume.
* It can take some time (2-3 minutes) for the service to launch in a
new container. You can tail the log to determine once Nexus is ready:
@@ -97,7 +123,7 @@ process, which runs as UID 200.
* There is an environment variable that is being used to pass JVM arguments to the startup script
* `INSTALL4J_ADD_VM_PARAMS`, passed to the Install4J startup script. Defaults to `-Xms1200m -Xmx1200m -XX:MaxDirectMemorySize=2g -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs`.
* `INSTALL4J_ADD_VM_PARAMS`, passed to the Install4J startup script. Defaults to `-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs`.
This can be adjusted at runtime:
@@ -124,8 +150,7 @@ There are two general approaches to handling persistent storage requirements
with Docker. See [Managing Data in Containers](https://docs.docker.com/engine/tutorials/dockervolumes/)
for additional information.
1. *Use a data volume*. Since data volumes are persistent
until no containers use them, a volume can be created specifically for
1. *Use a docker volume*. Since docker volumes are persistent, a volume can be created specifically for
this purpose. This is the recommended approach.
```
+192
View File
@@ -0,0 +1,192 @@
/*
* Copyright (c) 2020-present Sonatype, Inc. All rights reserved.
* Includes the third-party code listed at http://links.sonatype.com/products/clm/attributions.
* "Sonatype" is a trademark of Sonatype, Inc.
*/
/**
* This script triggers the build service for a certified docker image at Red Hat.
* It's meant to be used by Jenkins via the Jenkinsfile.
*/
@Grab('io.github.http-builder-ng:http-builder-ng-core:1.0.4')
import groovyx.net.http.HttpBuilder
import groovyx.net.http.HttpException
if (args.size() < 3) {
System.err.println('Usage: groovy TriggerRedhatBuild.groovy <version> <projectId> <apiKey>')
System.exit(1)
}
new BuildClient(*args).run()
class BuildClient {
private static final Integer TIMEOUT_MINUTES = 20
private final String version
private final String projectId
private final HttpBuilder builder
BuildClient(String version, String projectId, String apiKey) {
this.version = version
this.projectId = projectId
builder = HttpBuilder.configure {
request.uri = 'https://connect.redhat.com'
request.headers['Authorization'] = "Bearer ${apiKey}"
request.contentType = 'application/json'
request.body = [:]
}
}
/**
* fire off a series of requests to build and publish
* a container.
*/
void run() {
final nextTag = getNextTag(version)
println "Triggering build as ${nextTag}"
final buildStatus = build(nextTag)
if (buildStatus.status != 'Created') {
fail(buildStatus)
}
final completedBuild = getCompletedBuild(nextTag)
if (completedBuild.failure) {
fail(completedBuild.failure)
}
final published = publish(completedBuild.digest, completedBuild.name)
if (published.failure) {
fail(published.failure)
}
println published
}
/**
* calculate the cutoff time in the future in miliseconds
* for comparison to System.currentTimeMillis()
* @param start start time in millis
* @param minutes minutes into the future
* @return future time in millis
*/
private Long calcCutoffTime(Long start, Integer minutes) {
return minutes * 60 * 1000 + start
}
/**
* fail with message and exit with an error code for jenkins to see
* @param message message to print
*/
private void fail(String message) {
System.err.println(message)
System.exit(1)
}
/**
* Request current version tags available at Red Hat.
* @return the list of all tags
*/
private List getTags() {
return builder.post {
request.uri.path = "/api/v2/projects/${projectId}/tags"
}.tags
}
/**
* Request current version tags available at Red Hat,
* and calculate the next tag to use in this build.
* @param version the base version we're currently building
* @return the full new version string to submit for the next build
*/
private String getNextTag(String version) {
final tags = getTags()*.name.collectMany {
it.split(', ').collect()
}
final currentIndex = tags.findAll {
it.startsWith(version)
}.collect {
it.replaceAll(/${version}-(\d+)-?.*/, '$1') as Integer
}.sort().reverse()[0]
final nextIndex =((currentIndex ?: 0) as Integer) + 1
return "${version}-${nextIndex}"
}
/**
* Trigger build of the certified image at Red Hat,
* @param nextTag the full version tag to be assigned to the new build
* @return the map from json with the status of the submitted build
*/
private Map build(String nextTag) {
return builder.post {
request.uri.path = "/api/v2/projects/${projectId}/build"
request.body = [tag: nextTag]
}
}
/**
* Poll for the completed (built and scanned) build at Red Hat build service.
* @param nextTag the full version tag assigned to the new build
* @return the map from json with info about the completed build
*/
private Map getCompletedBuild(String nextTag) {
final endTime = calcCutoffTime(System.currentTimeMillis(), TIMEOUT_MINUTES)
while (System.currentTimeMillis() < endTime) {
println 'Waiting for build to finish.'
sleep 60000
try {
final completedBuild = getTags().find {
it.name == nextTag && it.scan_status == 'passed'
}
if (completedBuild) {
return completedBuild
}
} catch (HttpException ex) {
ex.printStackTrace()
System.err.println "Failed retrieving completed builds, but still trying: ${ex.statusCode} [${ex.body}]"
}
}
return [failure: "TIMEOUT waiting for complete build: ${TIMEOUT_MINUTES} minutes"]
}
/**
* Trigger publishing of the new image at Red Hat build service.
* @param digest hash string that identifies the container to publish
* @param name tag name (version) of the container image to publish
* @return the map from json with status of the published container image
*/
private Map publish(String digest, String name) {
final publishPath = [
'/api/v2/projects',
projectId,
'containers',
digest,
'tags',
name,
'publish'
].join('/')
try {
return builder.post {
request.uri.path = publishPath
}
} catch (HttpException ex) {
ex.printStackTrace()
return [failure: "Failed to publish: ${ex.statusCode} [${ex.body}]"]
}
}
}
+4 -15
View File
@@ -15,27 +15,16 @@
<%=
require 'json'
raise RuntimeError, 'environment variable DOCKER_TYPE is required' if ENV['DOCKER_TYPE'].nil? || ENV['DOCKER_TYPE'].empty?
raise RuntimeError, 'environment variable SONATYPE_DIR is required' if ENV['SONATYPE_DIR'].nil? || ENV['SONATYPE_DIR'].empty?
raise RuntimeError, 'environment variable NEXUS_HOME is required' if ENV['NEXUS_HOME'].nil? || ENV['NEXUS_HOME'].empty?
raise RuntimeError, 'environment variable NEXUS_DATA is required' if ENV['NEXUS_DATA'].nil? || ENV['NEXUS_DATA'].empty?
{
:run_list => [ 'recipe[nexus_repository_manager::docker]' ],
:run_list => [ "recipe[nexus_repository_manager::#{ENV['DOCKER_TYPE']}]" ],
:java => {
:jdk_version => ENV['JAVA_VERSION_MAJOR'],
:java_home => ENV['JAVA_HOME'],
:install_flavor => 'oracle',
:oracle => {
:accept_oracle_download_terms => true
},
:jdk => {
:'8' => {
:x86_64 => {
:url => ENV['JAVA_URL'],
:checksum => ENV['JAVA_DOWNLOAD_SHA256_HASH']
}
}
}
:install_flavor => 'openjdk',
:accept_license_agreement => true
},
:nexus_repository_manager => {
:version => ENV['NEXUS_VERSION'],