Fixed issue while validating the multibranch pipeline configuration #860
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This is a follow up PR for JENKINS-73474 where I'm fixing the issue while validating configuration when owner is set to empty.
Issue:
On click of validate, it iterates through all the
GHAppInstallation& check for valid repoownermatch but since its empty hence no match founds & throws an error.github-branch-source-plugin/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java
Lines 230 to 244 in fa7d412
whereas when user configures the Github app credentials at time also
Test Connectionsexecutes successfully without an error while owner is empty. It executes successfully because it reads the owner name fromGHAppInstallation.github-branch-source-plugin/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java
Lines 708 to 720 in fa7d412
Fix
Reading the repo owner name from the path & then verifying the connection. If its valid url then its executes successfully else it throws an error.
Manual Tests
Prerequisites:
New Item -> Multibranch pipeline -> Branch Source -> Add Github -> In Github section ->
Add new credentials where kind 'Github App' -> Add the appid & pem key -> In Advanced section keep owner as blank
vwagh-org1has the repo named asmultibranch-p1vwagh-org2not installed the github auth yetCase1: Invalid repo path
In Multibranch pipeline -> select the github credentials -> put the repository HTTPS url
i.e. https://github.com/vwagh-org2/multibranch-p1 -> Validate -> Angry jenkins
Case2: Valid repo path
Configure the repo url to https://github.com/vwagh-org1/multibranch-p1 -> Validate successfully.
Case3: Configure the wrong owner (i.e. org name) + test connection
Update credentials -> Advanced -> set owner to 'vwagh-org2' -> Test Connection -> Error
because vwagh-org2 don't have install the github auth yet
Case4: Install git auth + test connection
Next install the github auth on
vwagh-org2-> Test Connection -> Its successful.Case5: Configured wrong org + but valid repo path
Configure the wrong owner name i.e.
vwagh-org2-> Goto multibranch pipeline -> Configure -> put correct repo urlhttps://github.com/vwagh-org1/multibranch-p1 -> Angry Jenkins
Error logs
Case6: Configured valid org + valid repo path + Scan the repo
Configure the wrong owner name i.e. vwagh-org1 -> Goto multibranch pipeline -> Configure -> put correct repo url
https://github.com/vwagh-org1/multibranch-p1-> Validates successfullyNext scan the repo -> pipeline for main branch run successfully
Submitter checklist
Reviewer checklist
Documentation changes
Users/aliases to notify