Skip to content

Support job-dsl native syntax for folder-scoped github app credentials#1529

Open
justusbunsi wants to merge 1 commit into
jenkinsci:masterfrom
justusbunsi:job-dsl-folder-credentials-property
Open

Support job-dsl native syntax for folder-scoped github app credentials#1529
justusbunsi wants to merge 1 commit into
jenkinsci:masterfrom
justusbunsi:job-dsl-folder-credentials-property

Conversation

@justusbunsi

Copy link
Copy Markdown
Member

Description

These changes allows users to easily define folder-scoped github app credentials via job-dsl plugin. Without it, users would have to use the all-mighty "configure" callback to add those settings by xml modification. Sample job-dsl of what now works:

organizationFolder('sample') {
    organizations {
        github {
            repoOwner("jenkinsci")
            credentialsId("<credentials-id>")
        }
    }
    properties {
        folderCredentialsProperty {
            domainCredentials {
                domainCredentials {
                    domain {
                        name('folder.sample')
                        description('Folder-scoped credentials')
                    }
                    credentials {
                        // 👇 THIS HERE IS THE IMPORTANT PART
                        gitHubApp {
                            id('folder-scoped-github-app-credentials')
                            description('GitHub App for accessing repositories')
                            appID("...")
                            privateKey(Secret.fromString("""..."""))
                            repositoryAccessStrategy {
                                specificRepositories {
                                    owner('organisation-name')
                                    repositories(['repo-1', 'repo-2'])
                                }
                            }
                            defaultPermissionsStrategy('CONTENTS_READ')
                            scope('GLOBAL')
                        }
                        // ☝️ THIS HERE IS THE IMPORTANT PART
                    }
                }
            }
        }
    }
}

I am not sure if you want a test for this, and if it is even possible. Let me know if it is. I am happy to add one.

Submitter checklist

  • Link to JIRA ticket in description, if appropriate.
  • Change is code complete and matches issue description
  • Automated tests have been added to exercise the changes
  • Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.

Reviewer checklist

  • Run the changes and verify that the change matches the issue description
  • Reviewed the code
  • Verified that the appropriate tests have been written or valid explanation given

Documentation changes

  • Link to jenkins.io PR, or an explanation for why no doc changes are needed

Users/aliases to notify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant