===== Nexus ===== Nexus is a repository which is able to manage artifacts (jar files) for java, so that it can resolve its dependencies. === Deploy to Nexus === The user have to be authorized: == Paßwortdatei anlegen == XML-Datei C:\Users[KUERZEL]\.m2\settings-security.xml anlegen mit folgendem Inhalt MASTERPASSWORD_HERE Diese Datei nimmt das Master-Paßwort auf, das im nächsten Schritt erzeugt wird. == Passwörter anlegen== Eigenes Master-Paßwort wählen mvn --encrypt-master-password your_master_password Erzeugtes verschlüsseltes Master-Paßwort in settings-security einfügen. Die {} sind Teil des Paßworts. Benutzerpaßwort (IVU-Domänenpaßwort) ebenfalls verschlüsseln mvn --encrypt-password your_password Abschnitt in settings.xml suchen Es existieren darin zwei Tags , einer für Snapshots und einer für Releases Username darin auf den IVU-Login-Benutzer setzen Password auf das gerade verschlüsselte IVU-Login-Paßwort setzen mvn deploy:deploy-file -Dfile=android-4.1.2_r1.jar -DgroupId=android -DartifactId=android -Dversion=4.1.2_r1 -Dpackaging=jar -DrepositoryId=de.ivu.pto.p31.releases -Durl=http://ac-maven-build/nexus/content/repositories/releases/ mvn deploy:deploy-file -Dfile=android-4.1.2_r1.jar -DgroupId=android -DartifactId=android -Dversion=4.1.2_r1 -Dpackaging=jar -DrepositoryId=de.ivu.pto.p31.releases -Durl=http://ac-maven-build/nexus/content/repositories/releases/ ==== Artifacts ==== The artifacts available for deployment can be found here: |android|http://grepcode.com/snapshot/repo1.maven.org/maven2/com.jayway.maven.plugins.android.generation2/android-maven-plugin/4.1.2| ==== Install Nexus plugins ==== Here are the details: https://books.sonatype.com/nexus-book/reference/install-additional-plugins.html The structure of the nexus plugins looks as following: [nexus-name-plugin-version] dependencies META-INF nexus-name-plugin-version.jar To install plugins you have to unpack into the plugins into the folder **[SONATYPE-WORK-FOLDER]/nexus/plugin-repository** Example of **SONATYPE-WORK-FOLDER** /usr/share/tomcat7/sonatype-work/nexus/plugin-repository ==== P2 Update Sites ==== P2 Update Sites may be hosted on Nexus, by installing the maven Unzip Plugin: [[ http://repo1.maven.apache.org/maven2/org/eclipse/tycho/nexus/unzip-repository-plugin/0.14.0/unzip-repository-plugin-0.14.0-bundle.zip| it is hosted here]] |org.eclipse.tycho.nexus 0.14.0 | [[http://repo1.maven.apache.org/maven2/org/eclipse/tycho/nexus/unzip-repository-plugin/0.14.0/unzip-repository-plugin-0.14.0-bundle.zip|Maven2 repository]] | |org.sonatype.nexus 1-3 | [[http://repo1.maven.org/maven2/org/sonatype/nexus/plugins/nexus-unpack-plugin/|Maven2 repository]] | * deploy the update site to Nexus in a zip file * Maven may unzip the file on the fly and provide a URL The details about installation and configuration of the Nexus Unzip Plugin are here: https://wiki.eclipse.org/Tycho/Nexus_Unzip_Plugin ==== Cleaning All Snapshot Daily, but 1 ==== http://stackoverflow.com/questions/12660850/how-to-limit-number-of-deployed-snapshots-artifacts-in-nexus ==== Latest artefact from maven-repository ==== Details here: https://support.sonatype.com/entries/23674267-How-can-I-retrieve-a-snapshot-if-I-don-t-know-the-exact-filename- wget "http://repository.sonatype.org/service/local/artifact/maven/content?r=snapshots&g=org.sonatype.nexus&a=nexus-utils&v=LATEST" --content-disposition r = the id of the repository or group to search (Required) g = the groupId of the file (Required) a = the artifactId of the file (Required) v = the version of the file, this may be "LATEST", "RELEASE", a version number like "2.0", or a snapshot version number like "2.0-SNAPSHOT". (Required) c = the classifier of the file (Optional) e = the type or extension of the file (Optional) p = packaging (Nexus will resolve known packaging types to the correct extension). (Optional) ==== using curl==== Workin on a **raw** repository "rawtest" # upload curl.exe --fail -u admin:admin123 --upload-file ./Hello_Iam_an_artifact.txt.zip http://localhost:32553/repository/rawtest/ # delete via curl on Nexus # DELETING FOLDERS DONT WORK IN NEXUS3 curl -v --user admin:admin123 -X DELETE --write %{http_code} %{url_effective}\n --output /dev/null --silent http://nexus.otm.intra:32553/repository/rawtest/com/csg/cs/corex/lib/userpreferences-lib/7.3.0/userpreferences-lib-7.3.0-dirlist.txt curl -v --user admin:admin123 -X DELETE --write %{http_code} %{url_effective}\n --output /dev/null --silent http://nexus.otm.intra:32553/repository/rawtest/com/csg/cs/corex/lib/userpreferences-lib/7.3.0/userpreferences-lib-7.3.0-javadoc.jar curl -v --user admin:admin123 -X DELETE --write %{http_code} %{url_effective}\n --output /dev/null --silent http://nexus.otm.intra:32553/repository/rawtest/com/csg/cs/corex/lib/userpreferences-lib/7.3.0/userpreferences-lib-7.3.0-javadoc.jar.sha1 curl -v --user admin:admin123 -X DELETE --write %{http_code} %{url_effective}\n --output /dev/null --silent http://nexus.otm.intra:32553/repository/rawtest/com/csg/cs/corex/lib/userpreferences-lib/7.3.0/userpreferences-lib-7.3.0-sources.jar Workin on a **maven-type** repository curl -v -F "r=otmartifacts" -F "hasPom=false" -F "e=zip" -F "g=myapplication" -F "a=mytest" -F "v=6.2" -F "p=zip" -F "c=-2017-01-01" -F "file=@myFIleToUpload.txt" -u "USERNAMEX:mYpAssWord" http://nexus2x-efs.otm.intra:8081/nexus/service/local/artifact/maven/content ==== Upload using maven ==== To repos * artifacts-snapshots * artifacts-releases mvn deploy:deploy-file -DgroupId=com.dom -DartifactId=tom -Dversion=1.0.0 -DgeneratePom=false -Dpackaging=zip -DrepositoryId=artifacts-releases -Durl=http://localhost:32331/repository/artifacts-releases/ -Dfile=testartifact.zip mvn deploy:deploy-file -DgroupId=com.dom -DartifactId=tom -Dversion=1.0.0-SNAPSHOT -DgeneratePom=false -Dpackaging=zip -DrepositoryId=artifacts-snapshots -Durl=http://localhost:32331/repository/artifacts-snapshots/ -Dfile=testartifact.zip ==== Powershell script to import filesructure into the Nexus==== function GetFiles($path = $pwd, [string[]]$exclude) { foreach ($item in Get-ChildItem $path) { if ($exclude | Where {$item -like $_}) { continue } if (Test-Path $item.FullName -PathType Container) { $item GetFiles $item.FullName $exclude } else { if ($item.extension -eq ".jar") { $assoc = New-Object psobject -Property @{ Pom = "$($item.DirectoryName)\$($item.BaseName).pom" Jar = "$($item.DirectoryName)\$($item.BaseName).jar" } Write-Host "$($assoc.Pom) $($assoc.Jar)" & "C:\Users\csuser4\Downloads\apache-maven-3.3.9-bin\apache-maven-3.3.9\bin\mvn.cmd" deploy:deploy-file "-DrepositoryId=otm-gfm-repository" "-Durl=http://localhost:32553/repository/otm-gfm-repository/" "-DpomFile=$($assoc.Pom)" "-Dfile=$($assoc.Jar)" } } } } # $env:JAVA_HOME="C:\Program Files\Java\jdk1.8.0_102\" # $env:Path += ";C:\Program Files\Java\jdk1.8.0_102\bin" GetFiles("C:\data\cgf\repositoryTarget")