Publish/upload artifacts with Gradle or curl 1 2 3 4 5 6 7 8 9 10 11 12 13 gradle build publish -Djavax.net.ssl.trustStore=C:\Users\user\Desktop\me\workspace\me\kw-cacerts -Djavax.net.ssl.trustStorePassword=changeit -PNEXUS_REPO_URL=https:// repo.2 pswt.local:8443 /repository/m aven-releases/ -PNEXUS_REPO_USER=me -PNEXUS_REPO_PASSWORD=abc123. Direct upload curl -x socks5h:// localhost:8580 -k -v -u me:my-passwd --upload-file httpcore-4.4 .12 .pom https:// repo.2 pswt.local:8443 /repository/m aven-releases/org/ apache/httpcomponents/ httpcore/4.4.12/ httpcore-4.4 .12 .pom curl -x socks5h:// localhost:8580 -k -v -u me:my-passwd --upload-file spring-data-redis-2.5 .6 .jar https:// repo.2 pswt.local:8443 /repository/m aven-releases/org/ springframework/data/ spring-data-redis/2.5.6/ spring-data-redis-2.5 .6 .jar Upload jar with auto generating pom.xml curl -x socks5h:// localhost:8580 -k -v -u me:my-passwd -F "maven2.generate-pom=true" -F "maven2.groupId=spring-data-redis" -F "maven2.artifactId=spring-data-redis" -F "maven2.packaging=jar" -F "version=2.5.6" -F "maven2.asset1=@spring-data-redis-2.5.6.jar;type=application/java-archive" -F "maven2.asset1.extension=jar" "https://repo.2pswt.local:8443/service/rest/v1/components?repository=maven-releases" Upload jar and pom.xml (failed) curl -x socks5h:// localhost:8580 -k -v -u me:my-passwd -F "maven2.generate-pom=false" -F "maven2.asset1=@spring-data-redis-2.5.6.pom" -F "maven2.asset1.extension=pom" -F "maven2.asset2=@spring-data-redis-2.5.6.jar;type=application/java-archive" -F "maven2.asset2.extension=jar" "http://repo.2pswt.local:8443/service/rest/v1/components?repository=maven-releases"
Using sock5 proxy to clone git repo 1 2 3 4 5 git clone https://git.2pwst.local/wst-dev/xxx-service --config "http.proxy=socks5://127.0.0.1:8580" git config --global https.proxy "socks5://127.0.0.1:8080" git config --global --unset http.proxy git config --global --unset https.proxy
Referencehttps://help.sonatype.com/repomanager3/integrations/rest-and-integration-api/components-api https://help.sonatype.com/repomanager3/integrations/rest-and-integration-api/search-api
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 package hk .gov .cedb .tsw .upload ;import java .io .BufferedWriter ;import java .io .FileWriter ;import java .io .IOException ;import java .nio .file .FileVisitOption ;import java .nio .file .Files ;import java .nio .file .Paths ;import org .apache .commons .lang3 .StringUtils ;public class UploadArtificatToNexus { static String gradleCacheDir = "C:\\ Users\\ user\\ .gradle\\ caches\\ modules-2\\ files-2.1\\ com.squareup.okhttp3" ; static String filterVersion = "" ; static String repoUser = "me" ; static String repoPwd = "my-passwd" ; static String uploadJarScript = "curl -x socks5h://localhost:8580 -k -v -u " + repoUser + ":" + repoPwd + " -F \" maven2.generate-pom=false\" " + "-F \" maven2.groupId=%s\" -F \" maven2.artifactId=%s\" -F \" maven2.packaging=jar\" " + "-F \" version=%s\" -F \" maven2.asset1=@%s;type=application/java-archive\" " + "-F \" maven2.asset1.extension=jar\" \" https://repo.tswp2-dev.local:8443/service/rest/v1/components?repository=maven-releases\" " ; static String uploadPomScript = "curl -x socks5h://localhost:8580 -k -v -u " + repoUser + ":" + repoPwd + " --upload-file %s " + "https://repo.tswp2-dev.local:8443/repository/maven-releases/%s/%s/%s/%s" ; static String uploadNpmScript = "curl -x socks5h://localhost:8580 -k -v -u " + repoUser + ":" + repoPwd + " -F \" npm.asset=@C:\\ Users\\ user\\ Downloads\b abel-plugin-11.9.2.tgz;type=application/x-compressed\" " + "https://repo.tswp2-dev.local:8443/service/rest/v1/components?repository=npm-releases" ; public static void main (String [] args ) throws IOException { uploadArtifact (); } private static void uploadArtifact () throws IOException { BufferedWriter fw = new BufferedWriter (new FileWriter ("d:/artifacts.txt" )); try { Files .walk (Paths .get (gradleCacheDir ), FileVisitOption .FOLLOW_LINKS ).forEach (f - > { try { if (f .toFile ().isDirectory ()) { return ; } String fileName = f .getFileName ().toString (); if (fileName .contains ("source" )) { return ; } String version = f .getParent ().getParent ().toFile ().getName (); if (StringUtils .isNotBlank (filterVersion ) && ! filterVersion .equals (version )) { return ; } String artifactId = f .getParent ().getParent ().getParent ().toFile ().getName (); String groupId = f .getParent ().getParent ().getParent ().getParent ().toFile ().getName (); if (fileName .endsWith (version + ".jar" )) { String line = String .format (uploadJarScript , groupId , artifactId , version , f .toAbsolutePath ().toAbsolutePath ()); System .out .println (line ); fw .append (line + "\r \n " ); } if (fileName .endsWith (version + ".pom" )) { String line = String .format (uploadPomScript , f .toAbsolutePath (), groupId .replaceAll ("\\ ." , "/" ), artifactId , version , fileName ); System .out .println (line ); fw .append (line + "\r \n " ); } fw .flush (); } catch (IOException e ) { e .printStackTrace (); } }); fw .close (); } catch (IOException e ) { e .printStackTrace (); } } }