Automatically configure jenkins users using the CLI

I did not find links to user commands for the jenkins-cli tool.

I need this to automate the deployment.

Any comeback?

+7
source share
3 answers

You might not want to use the Jenkins internal user base at all. There are many plugins "Authentication and user management."

If you like MySQL, there is a MySQL authenticator (it reads the user table and passwords), and your adduser command can insert this table into this table.

If you like flat files, there is a "Script Security Realm" where you can authenticate using an arbitrary script. Write a file with user and password combinations in your favorite format, write an โ€œadduserโ€ script that writes to it, and write an auth script that reads the file and determines whether to authenticate the user.

You can also connect to an LDAP server, Active Directory, Atlassian Crowd, Unix accounts (pw_auth), or any other authentication used by your application server (for example, if it disconnects from the Tomcat server, you can tell Jenkins to let Tomcat authenticate users and configure Tomcat to do it as you want.

+3
source

If you specify in more detail what you are trying to do, people can help you better. However, here are a few pointers:

All CLI commands are available through http://[jenkins-server]/cli . What is not found is not available through the CLI. You can specify a username / password using the --username and --password (or --password-file ) options in CLI commands.

Another Jenkins automation option is to use the Python JenkinsAPI .

You can also use tools like wget and curl to perform certain actions (such as starting a build ). There you can use tokens for the user instead of the username / password.

Here is another link that may be helpful.

+3
source

To use the jenkins internal database, simply use the following command.

 echo 'jenkins.model.Jenkins.instance.securityRealm.createAccount("user1", "password123")' | \ java -jar jenkins-cli.jar -s http://localhost:8080/ groovy = 

This will create user = user1 with password = password123


If you have an existing user and you have anonymous access to your jenkins, you can specify a username and password using

- username "user_name" and password password "

+2
source

All Articles