Jenkins - getting "No type prefix:" when assigning roles - jenkins

I am trying to assign roles to users in Jenkins using the 'role based strategy' plugin. When I do that, I am getting a red text that says "No type prefix:" in front of every user that I am assigning a role to. Please advise how this can be removed.:
I am very new to Jenkins so any suggestions will be very helpful.
Regards
Ramesh

use "USER:" for user and "GROUP:" for group .. eg "USER:ABC" ..this changed with the recent plug in update ..

In order to resolve we have to add twice.
In your example
Under Global roles
Enter only jenkins and click on Add and click on admin checkbox
Enter USER:jenkins and click on Add and click on admin checkbox
Apply
Save
Similarly for all other users which needs admin role can be mapped.
The same approach can be used under Item and Node roles if it is configured
By doing this we would still see > No type prefix: jenkins however role based permission would work in desired way.
If you are locked out then use following link to get access again-
https://www.jenkins.io/doc/book/security/access-control/disable/
and follow above steps.

Just update plugins:
Matrix Authorization Strategy Plugin
Role-based Authorization Strategy

Related

How to create a user in jenkins?

I just installed Jenkins in my machine running Ubuntu.
But when I access http://localhost:8080/ jenkins asks me for my username and password... but I have no idea what they are!
How can I log in Jenkins? (Sorry for the noob question, first time using Jenkins)
Any help is welcome!
Edit: So far I got this:
I can remove security by changing the config.xml setting
<useSecurity>true</useSecurity>
to
<useSecurity>false</useSecurity>
And now I can access my Jenkins... But I still dont know how to create a user =/
in jenkins go to Manage Jenkins > Configure Global Security and select the "Enable Security" check box.
select "Jenkins Own User Database" for the security realm and then select "Logged in Users can do anything" or a matrix based strategy (If you have multiple users with different permissions) for the Authorization.
Once you log in Jenkins as admin, Manage Jenkins > Configure Global Security and select the "Enable Security" check box. select "Jenkins Own User Database" for the security realm under access control and then select "Logged in Users can do anything" under Authorization and Save it.
click on Manage jenkins>>Manage User >> Create User
Complete the details.
Jenkins asks me for my username and password... but I have no idea what they are!
It depends how you configured Jenkins Access Control/Security Realm in your Configure Global Security page which determines the user authentication method, whether to use Jenkins own independent user database or external database (such as LDAP, Active Directory, Unix NIS, etc.).
If its using its own database, you can try to decrypt Jenkins passwords from credentials.xml. Otherwise disable useSecurity in your config.xml file, restart Jenkins and follow the steps. You should be asked to provide the initial password from the initialAdminPassword file (if you don't, make sure you've changed the right file and restarted Jenkins correctly).
To create user, you need to go to select your authentication method in Configure Global Security and create user either externally or if you've selected Jenkins’ own user database and tick Allow users to sign up, then hit Save button which would allow you to create user from the Jenkins interface.
Login to your Jenkins server via web URL. (http://jenkins_ip or jenkins_url:8080)
Jenkins >> Manage Jenkins >> Manage Users >> Create User >> Provide the username, password, email & click on Create User.
To edit or reset or modify the password of the Jenkins' own user database users,
Jenkins >> Manage Jenkins >> Manage Users >> Click the user-id from the existing user list >> Configure >> Save
You should find a file in secrets folder called initialAdminPassword with the info
Steps to create a new user
Login into Jenkins
Go to Manage Jenkins
Go to Create Users
Enter all the details – Username, Password, Confirm Pwd, FullName, Email
Select Create User
This LINK has detailed steps on how to create Jenkins user.
Here is the summary:
After setting
<useSecurity>false</useSecurity>
Restart Jenkins:
sudo systemctl restart jenkins
Click on People on the left-hand navigation menu.
Click on the Admin. (Skip and move on to step 4 if you don't have any user).
Delete the user account.
Navigate to Jenkins / Manage Jenkins.
Click on Configure Global Security
Check the Enable Security check box. (If you don't have this item, skip and move on to next and you will able to create/add user)
Under Security Realm, select Jenkins’ own user database
In the Authorization section, select Logged-in users can do
anything.
Unselect Allow anonymous read access.
Click Save to save your changes.
By default Jenkins uses it's own database for user management.
Go to People on Jenkins dashboard to see Users that you have, if you are not able to find an option to add user there, don't be disheartened, read on.
Go to Manage Jenkins and scroll down to bottom, second last option should be Manage Users.
By default every logged-in user can do anything, to change this, go to Manage Jenkins -> Configure Global Security -> Access Control -> Authorization -> Matrix-based security
AT THIS POINT IF YOU DON'T KNOW WHAT TO DO, PLEASE DON'T MAKE ANY CHANGES. DON'T SAVE OR APPLY.

How to restrict in Jenkins users from viewing users information like: id, name etc

I have configured Jenkins on centos 7.
Being administrator, I have created few users and gave them permissions to their projects like: build, read etc.
I have used a Project-based Matrix Authorization Strategy. Its working but I'm facing the following problem:
If any user clicks on people information (button on left is dashboard) then any user can view all the other users ids, name etc. I want to block this from happening and I can't find a solution to this problem.
Can it be a configuration problem?
Here is one solution using the Role Strategy plugin.
I'm using this plugin for our Jenkins server and it's really useful to define permissions.
On my staging Jenkins, I've create 2 users:
A full admin
A viewer
I've created 2 roles with the plugin:
Next, I assign the roles to the relevant users:
The viewer role only have a global read access + build on the jobs.
If I open a session with the admin one, I can see all the people:
With the viewer user, I don't see anything:
UPDATE:
If you want to assign some permissions on a specific project, you can create project roles (in the Manage Roles section):
You can filter the projects with a regular expression:
job(.*)postcommit
Next, in the Assign Roles section, you just have to assign the relevant project role to the relevant user.
I hope it helps :)

Unable to create 'new job' in jenkins, OK button greyed out

I am trying to create a new job in Jenkins. Even after giving 'item name' and type of project as 'freestyle', the 'OK' button is greyed out as shown in the attached screenshot.
I am using :
Windows 7 32 bit OS
Jenkins version 1.619
Can anyone tell how to solve this issue.
Thanks in advance.
Check if the problem is related to your particular browser configuration.
Try with addons/plugins disabled, or in another browser.
Check the Jenkins logs under the logs folder to see if there's anything meaningful.
As the "People" tab in Jenkins says, it "Includes all known “users”, including login identities which the current security realm can enumerate, as well as people mentioned in commit messages in recorded changelogs."
To ensure that you have been assigned with appropriate role, ask a person with admin or dev rights, to go to Manage Jenkins -> Manage and Assign Roles -> Assign Roles, and then add you as user with appropriate rights.
Easy way to fix this issue
Before :
The OK button is disabled:
After :
Choosing any items and then OK will enable:

Jenkins security - hide all screens unless user is logged in

I don't know why "logged in users can do anything" means Jenkins will happily allow non-authenticated users to view project details and access artifacts... Regardless, I need to know how to get Jenkins to allow logged in users to to anything AND hide EVERYTHING for users who AREN'T logged in. Help please?
This can be done with the Role-Strategy plugin.
Install the plugin, add a new group called "Anonymous" and uncheck everything. Then you want to add another group called "authenticated" and check everything. Add your existing users to this group. Jenkins will immediately prompt you for a login this way.
You can use https://wiki.jenkins-ci.org/display/JENKINS/Role+Strategy+Plugin
it allows to specify to define roles and assign roles to users, users with no roles won't even see the jenkins ui.
Answer to an old question but I came searching here as I am trying to auto spin up a Jenkins instance on Docker and found the same issue.
Good chance this option wasn't available when the question was asked. As of this moment (v2.222.3 but not sure how far back), it turns out you can do this without installing any additional plugins.
Manually
Navigate to Global Security (Jenkins > Manage Jenkins > Global Security)
Update the Authorization section to "Logged-in users can do anything".
UNCHECK Allow anonymous read access
Any unauthenticated access will redirect to login now.
I would note that if you setup Jenkins through the setup wizard then anonymous read access is disabled by default. If you want this behaviour AND want to configure jenkins automatically, read on.
Automated with Docker
My situation is that I wanted to check out my repo, run my compose file and have all my config/users/plugins etc ready to go. Great post here with more detail if interested.
In a nutshell:
Dockerfile
FROM jenkins/jenkins:lts-alpine
# Disable setup wizard since security.groovy creates our user
ENV JAVA_OPTS="-Djenkins.install.runSetupWizard=false"
COPY security.groovy /usr/share/jenkins/ref/init.groovy.d/security.groovy
security.groovy
#!groovy
import jenkins.model.*
import hudson.security.*
def instance = Jenkins.getInstance()
// Create Admin User
def hudsonRealm = new HudsonPrivateSecurityRealm(false)
hudsonRealm.createAccount("admin", "admin") // Dont do this. This is bad
instance.setSecurityRealm(hudsonRealm)
// Set Auth to Full Control Once Logged In and prevent read-only access
def strategy = new FullControlOnceLoggedInAuthorizationStrategy()
strategy.setAllowAnonymousRead(false)
instance.setAuthorizationStrategy(strategy)
instance.save()
In particular, strategy.setAllowAnonymousRead(false) is what's needed
Additionally, if you use GitHub as your version control system -- you can use the GitHub OAuth plugin. Once the "Anonymous" reach your page, they will be redirected to GitHub automatically.

How can I add a username and password to Jenkins?

When I go to mydomain.example:8080 there is no authorization mechanism by default. I have had look at the configuration area but cannot find anywhere to add a basic username and password
Go to Manage Jenkins > Configure Global Security and select the Enable Security checkbox.
For the basic username/password authentication, I would recommend selecting Jenkins Own User Database for the security realm and then selecting Logged in Users can do anything or a matrix based strategy (in case when you have multiple users with different permissions) for the Authorization.
Assuming you have Manage Jenkins > Configure Global Security > Enable Security and Jenkins Own User Database checked you would go to:
Manage Jenkins > Manage Users > Create User
Try deleting the .jenkins folder from your system which is located ate the below path.
C:\Users\"Your PC Name"\.jenkins
Now download a fresh and a stable version of .war file from official website of jenkins. For eg. 2.1 and follow the steps to install.
You will be able to do via this method
You need to Enable security and set the security realm on the Configure Global Security page (see: Standard Security Setup) and choose the appropriate Authorization method (Security Realm).
Depending on your selection, create the user using appropriate method. Recommended method is to select Jenkins’ own user database and tick Allow users to sign up, hit Save button, then you should be able to create user from the Jenkins interface. Otherwise if you've chosen external database, you need to create the user there (e.g. if it's Unix database, use credentials of existing Linux/Unix users or create a standard user using shell interface).
See also: Creating user in Jenkins via API
If installed as an admin, use:
uname - admin
pw - the passkey that was generated during installation

Resources