Установка Nexus в Ubuntu описана в https://www.fosstechnix.com/how-to-install-nexus-repository-on-ubuntu/
Установлено в http://192.168.1.20:8081/#browse/browse
Каталоги nexus:
/home/vasi/tools/nexus/
/home/vasi/tools/sonatype-work/
Рестарт сервиса:
vasi@v:/etc/systemd/system$ sudo systemctl enable nexus vasi@v:/etc/systemd/system$ sudo systemctl restart nexus vasi@v:/etc/systemd/system$ ps -ax | grep nexus 181040 ? Sl 0:26 /usr/lib/jvm/java-17-openjdk-amd64/bin/java -server -Dinstall4j.jvmDir=/usr/lib/jvm/java-17-openjdk-amd64 -Dexe4j.moduleName=/home/vasi/tools/nexus/bin/nexus -XX:+UnlockDiagnosticVMOptions -Dinstall4j.launcherId=246 -Dinstall4j.swt=false -Di4jv=0 -Di4jv=0 -Di4jv=0 -Di4jv=0 -Di4jv=0 -Xms1024m -Xmx1024m -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=/home/vasi/tools/sonatype-work/nexus3/log/jvm.log -XX:-OmitStackTraceInFastThrow -Dkaraf.home=. -Dkaraf.base=. -Dkaraf.etc=etc/karaf -Djava.util.logging.config.file=etc/karaf/java.util.logging.properties -Dkaraf.data=/home/vasi/tools/sonatype-work/nexus3 -Dkaraf.log=/home/vasi/tools/sonatype-work/nexus3/log -Djava.io.tmpdir=/home/vasi/tools/sonatype-work/nexus3/tmp -Dkaraf.startLocalConsole=false -Djdk.tls.ephemeralDHKeySize=2048 --add-reads=java.xml=java.logging --add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED --patch-module java.base=./lib/endorsed/org.apache.karaf.specs.locator-4.3.9.jar --patch-module java.xml=./lib/endorsed/org.apache.karaf.specs.java.xml-4.3.9.jar --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.naming/javax.naming.spi=ALL-UNNAMED --add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED --add-exports=java.security.sasl/com.sun.security.sasl=ALL-UNNAMED -Di4j.vpt=true -classpath /home/vasi/tools/nexus/.install4j/i4jruntime.jar:/home/vasi/tools/nexus/lib/boot/nexus-main.jar:/home/vasi/tools/nexus/lib/boot/activation-1.1.jar:/home/vasi/tools/nexus/lib/boot/jakarta.xml.bind-api-2.3.3.jar:/home/vasi/tools/nexus/lib/boot/jaxb-runtime-2.3.3.jar:/home/vasi/tools/nexus/lib/boot/txw2-2.3.3.jar:/home/vasi/tools/nexus/lib/boot/istack-commons-runtime-3.0.10.jar:/home/vasi/tools/nexus/lib/boot/org.apache.karaf.main-4.3.9.jar:/home/vasi/tools/nexus/lib/boot/osgi.core-7.0.0.jar:/home/vasi/tools/nexus/lib/boot/org.apache.karaf.specs.activator-4.3.9.jar:/home/vasi/tools/nexus/lib/boot/org.apache.karaf.diagnostic.boot-4.3.9.jar:/home/vasi/tools/nexus/lib/boot/org.apache.karaf.jaas.boot-4.3.9.jar com.install4j.runtime.launcher.UnixLauncher start 9d17dc87 0 0 org.sonatype.nexus.karaf.NexusMain
User/pass: admin/pass (устанавливается при первом запуске)
$ cat /etc/systemd/system/nexus.service [Unit] Description=nexus service After=network.target [Service] Type=forking LimitNOFILE=65536 ExecStart=/home/vasi/tools/nexus/bin/nexus start ExecStop=/home/vasi/tools/nexus/bin/nexus stop User=vasi Restart=on-abort [Install] WantedBy=multi-user.target
Создать репозиторий ru.perm.v:
Результат deploy maven проекта https://github.com/cherepakhin/companies:
Результат deploy gradle kotlin проекта https://github.com/cherepakhin/vacancy_backend:
~/prog/kotlin/vacancy_backend$ ./gradlew publish BUILD SUCCESSFUL in 33s
Настройка deploy в build.gradle.kts (https://github.com/cherepakhin/vacancy_backend/blob/dev/build.gradle.kts):
repositories { mavenCentral() mavenLocal() maven { url = uri("http://v.perm.ru:8082/repository/ru.perm.v") //OK isAllowInsecureProtocol = true credentials { // username = "admin" // вариант задания credentials в build.gradle.kts // password = "pass" // Импорт переменных credentials из shell. Ниже задание значений shell переменных. username = System.getenv("NEXUS_CRED_USR") ?: extra.properties["nexus-ci-username"] as String? password = System.getenv("NEXUS_CRED_PASS") ?: extra.properties["nexus-ci-password"] as String? } } }
Задание значений shell переменных:
// Экспорт переменной NEXUS_CI_USER. $ export NEXUS_CI_USER=admin // проверка в shell $ echo $NEXUS_CI_USER $ export NEXUS_CI_PASS=pass $ echo $NEXUS_CI_PASS
Задание в Jenkins user/password для deploy в Nexus (ну и фразочка!)
Выяснить домашний каталог Jenkins из файла /etc/passwd. Пример:
v:~$ sudo cat /etc/passwd | grep jenkins jenkins:x:129:131:Jenkins,,,:/var/lib/jenkins:/bin/bash
В этом каталоге в подкаталоге .m2 (/var/lib/jenkins/.m2) разместить файл settings.xml со следующим содержанием:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
...
<server>
<id>ru.perm.v</id>
<username>admin</username>
<password>pass</password>
</server>
...
</servers>
</settings>