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-68755] Add support for explicit user and group assignment #230

Merged
merged 36 commits into from
Jul 6, 2023

Conversation

mawinter69
Copy link
Contributor

@mawinter69 mawinter69 commented Aug 5, 2022

Adding support to explicitly assign a role to a user or a group. This avoids confusion when a name matches both. A warning will be shown on the role assignment page for ambiguous entries with the possibility to make this a user or a group assignment.

❗ This is an incompatible change and after migration, going back to the previous version will require to undo the config changes. While the changes to the config.xml can be read by older versions, you can run into problems with duplicate entries.
Changes done on Configuration As Code yaml files need to be reverted to the old format before downgrading.

Config file changes

The new version can read an existing config.xml file. After startup of Jenkins with the new plugin version, the config.xml will be automatically saved with the new format. The new format basically just adds a new attribute to the sids

  <assignedSIDs>
    <sid>adminuser</sid>
    <sid>admingroup</sid>
  </assignedSIDs>

becomes (after applying user/group assignment via the UI)

  <assignedSIDs>
    <sid type="USER">adminuser</sid>
    <sid type="GROUP">admingroup</sid>
  </assignedSIDs>

(Without applying user/group it becomes

    <sid type="EITHER">adminuser</sid>

)

Configuration as Code changes

To read Configuration as code yaml files in the old format, please add the following to your casc yaml.

configuration-as-code:
  version: 1
  deprecated: warn

Without this addition startup will fail.

After starting Jenkins go to Assign Roles page and select for each entry in the table if the entry should be a user or a group.
Once all entries are adjusted save the changes. You can then go to Configuration as Code and look at the new format.
If you want to manually change you yaml files replace all occurrences of

assignments:
  - usersid1
  - usersid2
  - groupsid1
  - groupsid2

with

entries:
  - user: usersid1
  - user: usersid2
  - group: groupsid1
  - group: groupsid2

API Changes

The plugin APIs have significantly changed. Plugins that depend on role-strategy will probably need to be adjusted as well or might not work as expected (ownership-plugin, dynamic_extended_choice_parameter). Existing groovy scripts should be adjusted accordingly to avoid creating ambiguous entries.

  • 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

@mawinter69 mawinter69 requested a review from a team as a code owner August 5, 2022 14:55
@mawinter69 mawinter69 marked this pull request as draft August 5, 2022 14:55
@mawinter69 mawinter69 force-pushed the separate-user-group branch from 3b21c61 to 82ead83 Compare August 9, 2022 16:36
@mawinter69 mawinter69 changed the title [JENKINS-68755] Add support for explicit user and group assignmen [JENKINS-68755] Add support for explicit user and group assignment Dec 30, 2022
@mawinter69 mawinter69 marked this pull request as ready for review July 5, 2023 17:44
@mawinter69 mawinter69 force-pushed the separate-user-group branch from bbc4d7c to ed9a352 Compare July 6, 2023 16:19
@mawinter69 mawinter69 merged commit 398b8a2 into jenkinsci:master Jul 6, 2023
@mawinter69 mawinter69 deleted the separate-user-group branch July 13, 2023 20:19
@basil
Copy link
Member

basil commented Sep 1, 2023

Required Configuration as Code plugin tests to be adapted: jenkinsci/configuration-as-code-plugin#2357

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

Successfully merging this pull request may close these issues.

2 participants