[Continuous Integration CI/Continuous Deployment CD] 2. Docker installs Maven private server Nexus

This article is about a quick start and simple use case for installing and deploying Nexus3 private servers through Docker.

1. Installation

1. Obtain the latest version of nexus3 image through docker

docker pull sonatype/nexus3
Create a docker image to the host's disk mapping directory
Linux:
mkdir -p /home/nexus/data
chmod 777 -R /home/nexus/data
Windows:
Manually create any folder, such as:
F:\nexus3\data

2. Start the image


Start mirroring Linux with default parameter values :
docker run -d --name nexus3 -p 8033:8081 --restart always -v /home/nexus/data:/nexus-data sonatype/nexus3
Windows:
docker run -d --name nexus3 -p 8033:8081 --restart always -v F:/nexus3/data:/nexus-data sonatype/nexus3

Notes (non-essential operation, novices can ignore this step):
Note: You can customize the configuration parameters to run the Nexus mirroring program as needed. The
default private server data persistence directory in the mirroring is /nexus-data,
which can be accessed through -Djava.util. prefs.userRoot= NEXUSDATA / javaprefs parameter to configure, change the / nexus − data path to {NEXUS_DATA}/javaprefs parameter to configure, change the /nexus-data path toNEXUSDA T A / ja v a pre f s parameters to configure , / n e xu sThe d a t a path is changed to {NEXUS_DATA}/javaprefs
to control the Nexus Context Path through the NEXUS_CONTEXT variable, and the default valueNEXUS_CONTEXT=/
can be modified as needed. The example is:NEXUS_CONTEXT=nexus
by-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703msetting related services
:
docker run -d -p 8081:8081 --name nexus3 -e INSTALL4J_ADD_VM_PARAMS="-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -Djava.util.prefs.userRoot=/nexus-data2" sonatype/nexus3

3. Obtain a temporary password for first login, and then change it to a permanent password by default.

Method (1) Enter the container through the docker command to obtain the temporary login password corresponding to the default account admin

(1) Find the corresponding container id
docker ps -a

(2) Enter the command line of the container terminal
docker exec -it <容器id> /bin/bash



(3) Obtain the temporary password of the admin account under the corresponding directory file

cat /nexus-data/admin.password



(2) ) Directly find the corresponding admin.password file on the disk directory corresponding to the mirror image, and open it in text mode to view the temporary password of the admin account. For example, in

this article, the /nexus-data directory of the container is mapped to the F:\nexus3\data of the host disk directory, and then open admin.password as a text file to view the corresponding temporary password.

4. Enter the corresponding Nexus3 private server deployment address to access, and then modify the temporary password of the default account admin.


Login with admin account and temporary password

5. After the initial login is successful, a prompt will pop up. According to the default prompt, go to the second step to change the password of the admin account to be permanent.





Finally, after the password modification is completed, you can click sign out in the upper right corner to log out and log in again.

2. The following is the process of officially using Nexus3 private server

1. Create a warehouse

2. Select the warehouse type to create

3. Properties of the warehouse to be created

4. Add the warehouse you just created to the public group



Here you need to pay attention to adjusting the order of different nodes in the group. The corresponding jar packages will be loaded sequentially from top to bottom according to the order. Therefore, it is recommended that private servers be at the top and public warehouses be at the bottom.


5. Manually upload the jar package to the private server through the management panel



After the upload is successful, view it on the browse interface


3. The following is the process of automatically uploading the jar package to the Nexus private server through Maven automatic compilation and packaging under the IDEA tool.

1. Configure Maven's Settings.xml file, add the corresponding private server warehouse and the corresponding account password

Enter the maven installation directory D:\Program Files\apache-maven-3.8.2\conf and find Settings.xml to edit and configure


2. Add the account and password of the private server in the servers tab, and configure the type and address of the private server in the mirrors tab.

<servers>
  <server>
    <id>gitegg-release</id>
    <username>admin</username>
    <password>admin</password>
  </server>
  <server>
    <id>gitegg-snapshots</id>
    <username>admin</username>
    <password>admin</password>
  </server>
</servers>

<mirrors>
  <mirror>
    <id>alimaven</id>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>
  </mirror>
  <mirror>
    <id>nexus-gitegg</id>
    <url>http://localhost:8033/repository/maven-public/</url>
    <mirrorOf>*</mirrorOf>
  </mirror>
</mirrors>

3. Perform release configuration in the root pom.xml file of the project project

<project>
  <!--......-->

  <distributionManagement>
    <snapshotRepository>
      <id>gitegg-snapshots</id>
      <url>http://localhost:8033/repository/gitegg-snapshots/</url>
    </snapshotRepository>
    <repository>
      <id>gitegg-release</id>
      <url>http://localhost:8033/repository/gitegg-release/</url>
    </repository>
  </distributionManagement>
</project>

4. Finally, publish to the private server through the deploy option under the related project Lifecycle of the Maven tool under IDEA.

Note: Maven will automatically detect the naming of the version number and perform matching identification based on whether it contains the SNAPSHOT keyword.

When releasing a SNAPSHOT version, you must add the -SNAPSHOT suffix at the end of the version number, and then automatically publish to the snapshotRepository configuration node, example: 2.3.12-SNAPSHOT.

When a RELEASE version is released, as long as it does not contain the SNAPSHOT keyword, it will be recognized as a RELEASE version and automatically published to the repository node. According to the specification, the .RELEASE suffix should be added to the RELEASE version, such as 2.3.12.RELEASE.

5. After the release is successful, it can be viewed in the corresponding warehouse or group in Browse.

Guess you like

Origin blog.csdn.net/wmz1932/article/details/130806451