I'm trying to use Maven command line (mvn) to download a JAR file.
This post helped me to get to this nice command:
mvn dependency:get -Dartifact=<group>:<artifact-name>:<version> -DremoteRepositories=...
But I still could not figure out how to pass an auth token (since it is a private repository).
I also tryied to append -DhttpHeader="Authorization: Bearer ..." with no success, but I don't remember where did I get this.
How can I set an authorization token for it, please?
Related
Using following command(curl component API) to upload a pom file to Nexus 3 server.
curl -v -u account:password -X POST 'http://local_repo_address/service/rest/v1/components?repository='$repo -F maven2.groupId=$groupId -F maven2.artifactId=$artifactId -F maven2.version=$version -F maven2.asset1=#$=file_path -F maven2.asset1.extension=$file_type
Got 400 and following error.
[{"id":"*","message":"The provided POM file is invalid. Could not retrieve valid G:A:V parameters (com.xxx.xxx:xxx-xxx:${sdk.starter.version})"}]
Seem there is a placeholder in pom file and it's not valid for Nexus 3 component API.
I tried using maven deploy instead of API and it worked.
But is there any way that i could just upload it with API calling and bypass the validation?
If there is a property like ${sdk.starter.version} in the version tag, it does not make sense to upload the pom file (as it is) to Nexus. You will not be able to use or reference it from anywhere if it does not have a valid version number.
After a mvn deploy (to a local Nexus) on a project with more than 50 modules I realized that the deployed artifacts had all wrong file names (suffix zip instead of war etc).
Is there something like mvn undeploy to remove these from Nexus again?
You can delete it by using Curl command :
http://host:port/nexus/service/local/repositories/repo-id/content/group-id/artifact-id/version
The delete request can be sent with these parameters, I like to suppress the output except HTTP status code, so that it’s easier to check the result of a series of such commands run from shell script.
curl –request DELETE –write “%{http_code} %{url_effective}\\n” –user admin:admin123 –output /dev/null –silent url
For example you can execute this script from a Freestyle jenkins job.
can anyone tell me how we can run a curl command from jenkins.
I'm on windows 7 and i'm trying to put .sh on artifactory from a job jenkins.
thanks
So I understand that you want to upload a file to Artifactory by using curl and Artifactory's REST API?
The easiest would be to use the Artifactory plugin, and upload files from your workspace into an Artifactory repository.
If you want to do it without that:
Install cURL for Windows on the node
Add a "Windows batch script" build step, and call cURL with the right URL
I think I have run in to a maven deploy plugin bug, but I want to confirm that I am not doing it wrong before I open a bug report and start grepping through source.
I am trying to deploy an arbitrary binary (tar.gz,jar,box,etc) to a maven repository.
The user I am using is in the settings.xml file with a plaintext password.
The user is in an LDAP group that is connected to nexus with a Role.
That role has 3 privileges associated with it. Update, Create, Read which are in turn associated with the repository target.
Now using wget the user can pull data from the repo, and using this curl command I can deploy to the repo:
curl --request PUT --user USERNAME:PASSWORD https://NEXUS_URL/nexus/content/repositories/REPO_NAME/path/to/file/with/groupid/version/iamafile.jar \
--data #./iamafile.jar -H Content-Type:application/java-archive --verbose
This works fine, http 201 and the file is added. When I use a similiar mvn deploy command:
mvn deploy:deploy-file --settings /path/to/settings.xml \
-Durl=https://NEXUS_URL/nexus/content/repositories/REPOSITORYID -Dfile=iamafile.jar \
-DrepositoryId=REPOSITORYID -DartifactId=ARTIFACTID -DgroupId=GROUPID \
-Dversion=VERSION
I get an http 401 unauthorized error.
There have been multiple bug reports about this, but they supposedly have been fixed.
With a pom file with the same values for version, artifcatId, etc. mvn deploy works fine.
Have I found a bug, or am I using it improperly?
Edit:
I opened up this bug regarding the issue.
If the dev's end up saying that it isn't a bug, I will add that as an answer if someone hasn't beat me to it.
you need to additionally specify the -DrepositoryId
I'm trying to create a script to 'mavenize' a set of libraries. In order to make them available directly from an artifactory repository, i wanted the script to run the deploy command for each of my libs.
But i cannot seem to find the login+password command lines options; is the settings.xml file the only option to specify them ?
You can put the username and password in the URL:
http://username:password#hostname:port/path