Skip to content

Notify Commit: Ignore ssh subdomain to allow matching azure devops git ssh urls for notify #1758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

cschoell
Copy link

@cschoell cschoell commented May 22, 2025

Notify commit does not work with ssh and Azure DevOps.

Azure devops adds a "ssh." in front of the subdomain for git urls (ssh.dev.azure.com vs dev.azure.com). Hence the loose match for the host fails.
This is especially painful since azure devops jenkins plugin does not allow to send the ssh based url in the commit hook, but always sends the https based one.

I have updated the looselyMatches in GitStatus to ignore the prepended ssh. subdomain in the host.

Testing done

Added a unit test to check matching works and project is triggered.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@cschoell cschoell requested a review from a team as a code owner May 22, 2025 08:10
@github-actions github-actions bot added the tests Automated test addition or improvement label May 22, 2025
@cschoell cschoell changed the title Ignore ssh subdomain to match loosely with azure Devops Notify Commit: Ignore ssh subdomain to match loosely with azure Devops May 22, 2025
@cschoell cschoell changed the title Notify Commit: Ignore ssh subdomain to match loosely with azure Devops Notify Commit: Ignore ssh subdomain to allow matching azure devops ssh urls for notify May 23, 2025
@cschoell cschoell changed the title Notify Commit: Ignore ssh subdomain to allow matching azure devops ssh urls for notify Notify Commit: Ignore ssh subdomain to allow matching azure devops git ssh urls for notify May 23, 2025
https://github.com/jenkinsci/git-plugin/blob/master/CONTRIBUTING.adoc says:

> Code formatting in the git plugin varies between files. Try to maintain
> reasonable consistency with the existing files where feasible. Please
> don’t perform wholesale reformatting of a file without discussing
> with the current maintainers. New code should follow the SCM API code
> style guidelines.

The SCM API code style guidelines say:

https://github.com/jenkinsci/scm-api-plugin/blob/master/CONTRIBUTING.md#imports

For code in src/test:

> * imports of anything other than JUnit classes and Hamcrest matchers are banned.
> * static imports of anything other than JUnit classes and Hamcrest
>   matchers are strongly discouraged.
> * import static org.hamcrest.Matchers.*, import static org.junit.Assert.*
>   are expressly permitted. Any other static * imports are discouraged
>   unless code readability is significantly enhanced and the import is
>   restricted to a single class.
@MarkEWaite
Copy link
Contributor

MarkEWaite commented May 24, 2025

My account on visualstudio.com uses:

  • SSH URL [email protected]:v3/MarkEWaite/git-client-plugin/git-client-plugin
  • HTTPS URL https://markewaite.visualstudio.com/DefaultCollection/git-client-plugin/_git/git-client-plugin

Where can I find an Azure DevOps location that matches the URL's that are being changed here? As far as I can tell, my URL's don't fit the pattern that you're describing.

I removed the import reformatting in e500fa1 because import reformatting causes merge conflicts in other pull requests.

@cschoell
Copy link
Author

cschoell commented Jun 2, 2025

Hello @MarkEWaite

Our https url looks like this
https://dev.azure.com/organizationname/

While our ssh url looks like this:
ssh.dev.azure.com/organizationname/

It's the general pattern for azure devops.
As also mentioned e.g. here https://learn.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops

visualstudio.com has been moved to dev.azure.com as also mentioned in the link above.

image

A nice side effect with the new urls is that the path is actually the same for ssh and https - allowing the matching to work.

@MarkEWaite
Copy link
Contributor

MarkEWaite commented Jun 2, 2025

Our https url looks like this https://dev.azure.com/organizationname/

While our ssh url looks like this: ssh.dev.azure.com/organizationname/

It's the general pattern for azure devops.

I assume that must be the pattern for paying customers of Azure DevOps. I test with a free account and it remains https://markewaite.visualstudio.com/ with the repository hosted at https://markewaite.visualstudio.com/DefaultCollection/git-plugin/_git/git-plugin and [email protected]:v3/MarkEWaite/git-plugin/git-plugin

I can't afford to purchase Azure DevOps in order to test the changes. Is there another way that I can be granted access to Azure DevOps at the dev.azure.com URL?

@cschoell
Copy link
Author

cschoell commented Jun 2, 2025

According to azure devops website you can get unlimited free private repos.
https://azure.microsoft.com/en-us/products/devops/repos

Also in your organization settings there should be an option to migrate the url from visualstudio.com to dev.azure.com

See also here https://stackoverflow.com/questions/60279119/migrating-from-myorg-visualstudio-com-to-dev-azure-com-myorg

I also checked the paths for cloning in azure devops again

for https it looks like this:

https://[email protected]/myorg/PROJECT/_git/repositoryname

and for ssh like this:

[email protected]:v3/myorg/PROJECT/repositoryname

I assume it would also be required to replace /_git/ with / for the matching to work. I actually missed that part.

I have added that change to the PR.

@cschoell
Copy link
Author

cschoell commented Jun 2, 2025

I actually added the urls as they are used in azure devops to the unit test. There is also a version part in the ssh url (:v3/) which would need to be ignored.

@MarkEWaite
Copy link
Contributor

Also in your organization settings there should be an option to migrate the url from visualstudio.com to dev.azure.com

Thanks for the pointer. I found it in the organization settings and have moved my organization to https://dev.azure.com/MarkEWaite/ . Now I need to find all the locations that reference the old URL and replacement them with the new URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Automated test addition or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants