Maven release of Github project fails for using wrong Github account - macos

I'm performing a release of a project on Github using Maven. release:prepare fails with:
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] remote: Permission to FOO/BAR.git denied to BAZ.
[ERROR] fatal: unable to access 'https://github.com/FOO/BAR.git/': The requested URL returned error: 403
The weird thing is that BAZ is the "wrong" github.com account. It is one of two user names I use on Github, but not one I have ever used with the BAR project. Let's say the right account is FIZZ.
SCM settings don't specify a user name:
<scm>
<connection>scm:git:https://github.com/FOO/BAR.git</connection>
<url>scm:git:https://github.com/FOO/BAR.git</url>
<developerConnection>scm:git:https://github.com/FOO/BAR.git</developerConnection>
...
</scm>
(FOO is an organization that I'm part of.) In fact, I can't figure out where on earth BAZ is coming from. It's not in ~/.gitconfig or .git/config. There is no ~/.m2/settings.xml file. My Maven settings.xml file says nothing about Github.
If I use git on the command line it works -- push is fine for example.
Can anyone tell me where else this might be coming from? a hidden config file or directory somewhere, whether Maven- or Git-related?
Or, what's the best practice for recording the Github user to use in a private local file, like a Maven settings.xml or .git/config, such that I need not put my own user into the build file?
I'm using Mac OS X.

The simplest thing would be to explicitly use an ssh url, see more details in this answer.
git remote set-url origin git#github.com:FIZZ/FOO/BAR.git

Finally figured this out. The problem is that I'm on OS X, and had logged in to my second account BAZ via Safari. This saved the username and password for https://github.com in Keychain. Apparently, the Maven SCM plugin consults this for HTTPS URLs, although git won't. After clearing Keychain, it correctly prompted me for a username and password.

Related

Build Error while building aperturejs

I am trying to build aperturejs with Readme.md instructions.
I cloned the repository and tried the command mvn clean install in the root directory of ApertureJs.
I got the following Build Error as in the screenshot,
I am using the latest version of Maven - 3.3.9
Thanks in advance.
By reading the error in your console, I could feel that you are not authorized to access the particular repository, which is shown in your console.
Copy the repository url and try it from a browser - hope you will not be able to access the repository, since you are not authorized.
Raise appropriate access and after getting access, then try mvn clean install.
Below is the Quick fix till the time you get the access:
Copy and Paste the respective jar/pom/folder from your colleague machine, in your .m2/repository/...
Run the mvn clean install with -o option so that it will look into your local repository for building your application
Thank you. The issue is solved. I posted this issue to Uncharted Software's Salt Repository and exactly like Clement Said, I was trying to access a repository that no more has access publicly. Therefore they gave a workaround.
It is available here -> https://github.com/unchartedsoftware/aperturejs/issues/22
Thanks a lot.

Artifactory not resolving local snapshots

I'm trying to resolve SNAPSHOTS artifacts deployed on the local repository (libs-snapshots-local) but I'm having an unexpected behavior :
when wgetting my/group/artifact/1.0-SNAPSHOT/artifact-1.0-SNAPSHOT.jar artifactory redirects me to my/group/artifact/1.0-SNAPSHOT/artifact-1.0-SNAPSHOT.jar/ (same url with a slash added)
then the subsequent request will fail with error 404
Does anyone know how to fix this ? Is this happening to anyone ?
UPDATE:
If I try to resolve the artifact using the libs-snapshots-local the download will succeeed but if I try with the virtual repository repo it will not work:
wget http://artifactory:8080/repo/my/group/artifact/1.0-SNAPSHOT/artifact-1.0-SNAPSHOT.jar = REDIRECT then 404
wget http://artifactory:8080/libs-snapshots-local/my/group/artifact/1.0-SNAPSHOT/artifact-1.0-SNAPSHOT.jar = OK
But the virtual repository repo should contains all the other repository by default (and I don't know if it is even possible to change this behavior).
The root cause of this issue is related to a redirect performed by a remote Maven repository - http://mirrors.ibiblio.org/pub/mirrors/maven2.
In some cases this redirect will cause Artifactory to assume it got a proper response from the remote repository while actually it is not the expected type of response (getting an HTML document with the repository listing instead of an artifact content).
For more details see the answer to this question

Maven release plugin not using configured username

I am using maven-release-plugin:2.5.1. I need to configure it to connect to SVN using public/private key authentication. I'm having problems getting the configuration to use the correct username when attempting the SSH connection to SVN.
My deploy-settings.xml <server> config looks like:
<server>
<id>my.server.org</id>
  <username>[XXXX]</username>
  <privateKey>/home/[YYYY]/.ssh/id_rsa</privateKey>
</server>
My pom.xml <scm> config looks like:
scm:svn:svn+ssh://my.server.org/data1/svns_zzzz/zzzz/path/to/the/project/trunk
My mvn command line looks like:
--batch-mode release:clean release:prepare release:perform
-s /home/[YYYY]/.m2/deploy-settings.xml
-Dsettings.security=/home/[YYYY]/.m2/master-settings.xml
When I tried the above configuration it failed. It could not commit the modified POM file to SVN. To help debug this problem, I set the following environment variable:
SVN_SSH="ssh -vvv"
When I did this, I saw in the debug statements too many authentication failures with a username other than the [XXXX] username defined in the <server> tag.
So then I tried to specify the username in the command line:
--batch-mode -Dusername=[XXXX] release:clean release:prepare release:perform...
That didn't work.
So then I tried to specify the username in the POM:
scm:svn:svn+ssh://[XXXX]#my.server.org/data1/svns_zzzz/zzzz/path/to/the/project/trunk
That didn't work either.
To debug and verify my [XXXX] username and /home/[YYYY]/.ssh/id_rsa key did in fact work, I added them to the environment variable:
SVN_SSH="ssh -vvv -l [XXXX] -i /home/[YYYY]/.ssh/id_rsa"
After setting the environment variable like this, it worked. The release plugin was able to successfully commit the modified POM file to SVN. So I know the username and password work.
So now the question is what is wrong with my Maven configuration? Setting the SVN_SSH environment variable helped diagnose the problem, and provides a work-around but I don't want to leave it as a long-term solution.
Any thoughts?
The release plugin forks the build, and doesn't pass the arguments you provide on the command line to the forked process by default. Try adding this: -Darguments="-s /home/[YYYY]/.m2/deploy-settings.xml -Dsettings.security=/home/[YYYY]/.m2/master-settings.xml" (note double quotes) to the current command line. This should pass the changes to the forked processes.

Passing through credentials for nexus while using maven release plugin

I would like to use credentials of the physical user during the release. I use following stack: my own maven plugin wrapping maven-release-plugin, jenkins, nexus, git. On Jenkins I use parameters and password mask plugin to provide username and password for the user who is executing the build. The problem is that credentials for Jenkins, Git and Nexus may be different, so I can NOT re-use them. Obviously I could use CI user to authenticate everything but because of some regulations I can not do that.
First I tried to use -Dusername and -Dpassword but 1) this works only for git, 2) password for git and nexus is different. Besides that I want to use key based authentication for git.
Then I tried to programmatically change credentials by changing session/project object before executing maven-release-plugin:
final MavenExecutionRequest request = new DefaultMavenExecutionRequest()
.setLocalRepository(session.getLocalRepository())
.setPluginArtifactRepositories(session.getCurrentProject().getPluginArtifactRepositories())
.setRemoteRepositories(session.getCurrentProject().getRemoteArtifactRepositories())
.setBaseDirectory(new File(properties.getCheckoutDirectory()))
.setPluginGroups(session.getPluginGroups())
.setProjectPresent(true)
.setPom(new File(properties.getCheckoutDirectory() + "/pom.xml"))
.setGoals(Arrays.asList(goal))
.setInteractiveMode(false)
.setUserSettingsFile(new File(session.getSystemProperties().getProperty("user.home") + "/.m2/settings.xml"))
;
request.setUserProperties(preparePropertiesForMvn(properties));
for (ArtifactRepository artifactRepository : session.getCurrentProject().getRemoteArtifactRepositories()) {
if (artifactRepository.getId().equals("nexus-releases")) {
artifactRepository.setAuthentication(new Authentication(properties.getNexusUser(),properties.getNexusPassword()));
}
}
final MavenExecutionResult result = defaultMaven.execute(request);
At very end stage maven-deploy-plugin (which is executed by release plugin) reads ~/.m2/settings.xml file and gets (wrong - CI) credentials from it.
Is there the other way than preparing own customized settings.xml file for the build with builded in credentials? I would like to avoid to store the credentials on the local storage.
You can use the following method to add your own server configuration:
org.apache.maven.settings.Settings.addServer(org.apache.maven.settings.Server)
Tested and verified with help:effective-settings as I have no means to test agains any repository manager at the moment.
As long as you call the above method with your own server configuration ahead of the Maven deploy plugin, you should be good to go.
Server server = new Server();
server.setId("myServer");
server.setUsername("myUserName");
server.setPassword("myPassword");
settings.addServer(server);

Why won’t Jenkins running on my Mac connect to a local git repo?

I am trying to implement automated builds using Jenkins for my iOS projects. I added the Git plugin, but as soon as I try to put the URL for git in the git configuration for the project, it is showing the error in the screen shot below. Here Jenkins cannot clone from the repo to its workspace.
For the "Repository URL" field it is expecting a remote repository URL, something like git#github.com:github/hubot.git. It will use that url to copy down code to run the job against.
If you just want to run a job in a particular directory where you already have the code you want to work against, then leave this section empty. You can set the directory that you want to run a job in by
1. scroll to the "Advanced Project Options" section
2. click "Advanced"
3. Check "Use custom workspace"
For one off things, this is fine, but if you use this a lot, I think you'll find it more useful to commit your code to github and have jenkins clone down a fresh copy of code for each run.
You will get that error if you miss the following cases:
Whenever the clone URL is wrong.
When you are trying to clone from a place where you don't have the
access to git server.
Whenever your Pem key is not added to the list of keys on the git
server.
In most cases git bare repo has extension .git
I mean (other)/test1 dont look correct, i think it should be (other)/test1.git had this same error on my mac.
Actually i solved the issue . it was because of the permission the remote git is not updating properly

Resources