Skip to content
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

[JENKINS-73677] Decorate GitClient after adding credentials #1687

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

Dohbedoh
Copy link
Contributor

@Dohbedoh Dohbedoh commented Nov 4, 2024

(second attempt of #1649)

JENKINS-73677: Credentials are added to GitClient after the client is decorated by extensions.. A plugin cannot for example override the credentials passed in via a GitSCMExtension (Noticed as part of jenkinsci/bitbucket-branch-source-plugin#867)

Testing done

Tested simple scenario: configured Pipeline from SCM with GitSCM with provided Credentials.
Tested other scenario: configured Multibranch SCM with Bitbucket Branch Source.
Tested other scenario: configured Multibranch SCM with Bitbucket Branch Source with SSH Credentials trait.

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 demonstrates feature works or fixes the issue

@Dohbedoh Dohbedoh requested a review from a team as a code owner November 4, 2024 03:19
@Dohbedoh Dohbedoh marked this pull request as draft November 4, 2024 03:19
@github-actions github-actions bot added the tests Automated test addition or improvement label Nov 4, 2024
@nfalco79
Copy link
Member

nfalco79 commented Nov 6, 2024

bitbucket-branch-source-plugin has been released with workaround that make SSH works with this patch

@Dohbedoh
Copy link
Contributor Author

@MarkEWaite Any chance to get this merged ? Bitbucket Branch Source should be ready now. cc @nfalco79

@nfalco79
Copy link
Member

Yes please. Merging this fix, enable us to fix the authentication issues in Bitbucket plugin

@MarkEWaite
Copy link
Contributor

@MarkEWaite Any chance to get this merged ? Bitbucket Branch Source should be ready now. cc @nfalco79

I'm leaving town until next Monday 2 Dec 2024. I'll plan to test it and release it the week of 2 Dec 2024.

@MarkEWaite MarkEWaite changed the title [JENKINS-73677] Reapply: Decorate GitClient after adding credentials [JENKINS-73677] Decorate GitClient after adding credentials Dec 2, 2024
@MarkEWaite MarkEWaite added bug Incorrect or flawed behavior and removed tests Automated test addition or improvement labels Dec 2, 2024
@MarkEWaite MarkEWaite merged commit 7a4955e into jenkinsci:master Dec 2, 2024
18 checks passed
MarkEWaite added a commit to MarkEWaite/bom that referenced this pull request Dec 3, 2024
Git client plugin 6.1.1-rc3643.ff37e600016d includes JGit 7.1.0.
JGit 7.1.0 is scheduled to release 4 Dec 2024, so there is a small chance
that the version will be updated before the official release.

Git client plugin pull request for JGit 7.1.0 is:

* jenkinsci/git-client-plugin#1220

JGit 7.1.0 release notes are:

* https://projects.eclipse.org/projects/technology.jgit/releases/7.1.0

Git plugin 5.6.1-rc5357.7a_4955e76288 adds credentials to the GitClient
object before decorating the object with settings from extensions.
A plugin that adds a deocrator will now be able to adjust the credentials
if needed.

* jenkinsci/git-plugin#1687
* https://issues.jenkins.io/browse/JENKINS-73677

Tested by running:

PLUGINS=github-branch-source,cloudbees-bitbucket-branch-source,,mailer TEST=InjectedTest bash local-test.sh
@Dohbedoh Dohbedoh deleted the JENKINS-73677 branch December 4, 2024 09:28
@sandeepbarnwal
Copy link

@MarkEWaite Any chance to get this merged ? Bitbucket Branch Source should be ready now. cc @nfalco79

I'm leaving town until next Monday 2 Dec 2024. I'll plan to test it and release it the week of 2 Dec 2024.
@MarkEWaite I wanted to check if the release is still on track, as I’m also waiting on it. Please Let me know.

@MarkEWaite
Copy link
Contributor

I'm leaving town until next Monday 2 Dec 2024. I'll plan to test it and release it the week of 2 Dec 2024.

@MarkEWaite I wanted to check if the release is still on track, as I’m also waiting on it. Please Let me know.

I started the testing last week with a pull request to the plugin BOM. You can read more about the adventures there:

I still need to run the acceptance test harness with the git plugin pre-release. Unfortunately, there is a distraction in the acceptance test harness due to currently failing tests as noted in two pull requests:

The acceptance test harness distraction won't prevent the release, but it did need some time yesterday to understand what was causing the test failure. I hope to release this week.

@sandeepbarnwal have you tested the pre-release build and confirmed that it works for your use case? The incremental build instructions include these links:

Deployed version 5.6.1-rc5359.61d411e35db_a_ to Incrementals

Download link:

git

Plugin Installation Manager input format: (documentation)

git:incrementals;org.jenkins-ci.plugins;5.6.1-rc5359.61d411e35db_a_

@sandeepbarnwal
Copy link

I'm leaving town until next Monday 2 Dec 2024. I'll plan to test it and release it the week of 2 Dec 2024.

@MarkEWaite I wanted to check if the release is still on track, as I’m also waiting on it. Please Let me know.

I started the testing last week with a pull request to the plugin BOM. You can read more about the adventures there:

I still need to run the acceptance test harness with the git plugin pre-release. Unfortunately, there is a distraction in the acceptance test harness due to currently failing tests as noted in two pull requests:

The acceptance test harness distraction won't prevent the release, but it did need some time yesterday to understand what was causing the test failure. I hope to release this week.

@sandeepbarnwal have you tested the pre-release build and confirmed that it works for your use case? The incremental build instructions include these links:

Deployed version 5.6.1-rc5359.61d411e35db_a_ to Incrementals

Download link:

git

Plugin Installation Manager input format: (documentation)

git:incrementals;org.jenkins-ci.plugins;5.6.1-rc5359.61d411e35db_a_

Tested with suggested verson of git plugin and a version of bitbucket branch source plugin that doesn't have the workaround fix and it didn't work for me.

image image Error: image

@nfalco79
Copy link
Member

We have merge fix jenkinsci/bitbucket-branch-source-plugin#899 into master.
We are waiting git-plugin is released to also release bitbucket-source-plugin

@sandeepbarnwal
Copy link

sandeepbarnwal commented Dec 11, 2024

We have merge fix jenkinsci/bitbucket-branch-source-plugin#899 into master. We are waiting git-plugin is released to also release bitbucket-source-plugin

This bitbucket release already contains a workaround. Does that mean master has workaround fix and jenkinsci/bitbucket-branch-source-plugin#899 both? was it tested earlier without the workaround ?

@SunMar
Copy link

SunMar commented Dec 11, 2024

I've built the Bitbucket Branch Source plugin on my computer from the master branch, and installed for the git plugin version 5.6.1-rc5359.61d411e35db_a_. With that setup I did a test and it works again for me with SSH credentials.

@sandeepbarnwal
Copy link

I've built the Bitbucket Branch Source plugin on my computer from the master branch, and installed for the git plugin version 5.6.1-rc5359.61d411e35db_a_. With that setup I did a test and it works again for me with SSH credentials.

Master branch would have the workaround fix and I'm testing with username and password credential for my case.
could you try with any version of bitbucket before 921.v6a_215c8b_f095?

@SunMar
Copy link

SunMar commented Dec 11, 2024

@sandeepbarnwal I can only test my own use case, which is using username+token for discovery and SSH for checkout (jenkinsci/bitbucket-branch-source-plugin#866). The workaround doesn't solve that, it's still broken in the latest release (but fixed now for me in master).

If you want to test the master branch yourself and you have Docker installed you can easily build the plugin from source by running the following command from the directory where you cloned the plugin repository:

docker run --rm -v "$(pwd):/app" -u ubuntu -w /app -it maven:3-eclipse-temurin-17 bash -c 'mvn clean install -DskipTests && mvn package -DskipTests'

That will create a file cloudbees-bitbucket-branch-source.hpi in the target/ directory which you can install in Jenkins.

@MarkEWaite
Copy link
Contributor

No need to build the plugin yourself. Incremental builds of plugins are generated by ci.jenkins.io and can be downloaded from ci.jenkins.io or from the instructions that are included in the GitHub checks for plugin branches and for plugin pull requests. We need to add a section "Using incrementals" to the existing developer page. It would need to say something like this (improvement suggestions are welcomed):

Using Incrementals with Plugin Manager

Once incrementals are enabled for a plugin, Jenkins administrators and other Jenkins users can use the incremental build on their Jenkins controller by downloading it from ci.jenkins.io.

Copy the URL from the specific build on ci.jenkins.io

URL-from-ci-jenkins-io

Paste the URL into the Jenkins plugin manager

URL-to-your-jenkins-pliugin-manager

Using Incrementals with Configuration as Code

Instructions for the plugins.txt file and a download link are also available from the GitHub checks for branches and for pull requests.

Finding Incrementals from GitHub Checks for a Jenkins job

github-from-ci-jenkins-io

Finding Incrementals from GitHub Checks for a Branch

github-checks-for-a-branch

Finding Incrementals from GitHub Checks for a Pull Request

github-checks-for-a-pull-request

@nfalco79
Copy link
Member

Does that mean master has workaround fix and jenkinsci/bitbucket-branch-source-plugin#899 both?

Yes, the correct version to use with this pr is master. Any other version will fall into a bug. Only this PR + bitbucket master cover all use case. Credentialsid is NEVER null and user credential is contributed/overridden by the git extension in some use case and in other let git-plugin rely on stored credentials.
Any other conbination will not work at all.

@sandeepbarnwal
Copy link

Thanks for your help! It's working fine for me now.
I realized I had missed pulling the latest changes from the original Bitbucket repository and had only done a git pull from my forked version.

MarkEWaite added a commit to MarkEWaite/docker-lfs that referenced this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect or flawed behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants