Using Jenkins CLI to configure plugins - jenkins

I am working on installing and configuring Jenkins automatically using the Jenkins CLI. I am able to install plugins such as the Active Directory plugin, but haven't figured out how to configure it. Is it possible to perform such tasks from the CLI? From a Jenkins GUI standpoint, I'd like to check the Enable security checkbox under Security Realm check the Active Directory option, provide parameters to Active Directory, and under Authorization check the Anyone can do anything option.
I'm using a Puppet module (https://forge.puppetlabs.com/rtyler/jenkins) for the automation.
Greetings,
Kenneth

If you want to modify their configuration files manually using scripts called from the CLI, then yes.
Else, I don't believe there is. At least, not a general way for all plugins. Plugins are capable of adding CLI commands, as per this documentation page:
https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI
Extending CLI
Plugins installed on Jenkins server can add custom CLI commands. See Writing CLI commands for more details.
So, some of the plugins you're using may have specific commands to configure them from the CLI.
So as far as I know those are your options. Manual configuration through editing their config files, or hoping your plugin includes some commands in the CLI that is specific to it.

There is currently a new Plugin in development called "Configuration as Code Plugin" to provide a way for configuration of plugins using YAML: https://github.com/jenkinsci/configuration-as-code-plugin/
They are currently in an early development stage but this could help solve this kind of problem.

Related

How to automate the configuration of LDAP and other plugins for Jenkins using ansible or some other tool

I am working on a project where I need to automate the LDAP and other plugin configuration without manual intervention .Is this possible using Ansible?Or can experts some one suggest a better way to do it.Thank you
The recommended approach for configuring plugins is JCasC. You must inatall the JCasC plugin. LDAP plugin supports JCasC.
Note: JCasC does not manage the installation of plugins themselves, that's a separate topic, just the configuration.

There is no AWS Codedeploy Plugin in Jenkins

I use two different Jenkins servers(tomcat jenkins) and i was trying to install a plugin for aws codedeploy.
However, I couldn't find it in the list of a Jenkins but another one has it.
Why the plugin libraries are different? even though i install them in a same way.
Also, How can i add a particular plugin in my Jenkins server?
Thank you.
Why the plugin libraries are different?
The plugin libraries shouldn't be different.
Which way did you search the plugin (jenkins gui, in the web)? Both your servers are on the same Jenkins version?
Also, How can i add a particular plugin in my Jenkins server?
I do it always via the GUI as described here: https://jenkins.io/doc/book/managing/plugins/

How can I determine the syntax version without management permissions?

How can I determine what version of the declarative pipeline syntax is available to me when writing a Jenkinsfile if I do not have the permissions needed to list the plugins in the Jenkins server?
I am trying to write a Jenkinsfile using the declarative syntax, but cannot tell if the errors I encounter are because I am misinterpreting the documentation or if I am referencing documentation for a newer version than available on the box.
I have access to Jenkins server to configure and run a build. However, I have no management or script permissions over Jenkins itself, so none of the options on How to get a list of installed jenkins plugins with name and version pair? worked for me.
Perhaps there is a way to make my Jenkinsfile echo the relevant version information as part of its execution? Or some easy syntax tests that (based on pass/failure) would prove which syntax version is available?
This might be helpful, depending on version of Jenkins, but a note at the bottom said this was blocked more than a year ago. So there probably isn't a way to do it without admin access. You can use the REST API, CLI, or script console, but all fo these require admin access.
https://support.cloudbees.com/hc/en-us/articles/218756317-How-can-non-admin-users-view-the-installed-plugins-

How to use configuration management to configure Jenkins?

I am looking for a way to add/remove/update Jenkins master environment variables using some way of configuration management.
If this can be done with Ansible even better.
Please note that I would like to avoid patching the config.xml file manually, especially because this would risk to create issues and a Jenkins restart would be required and this is to be avoided whenever is possible.
In case it was not clear, I am trying to find an automation solution for altering Manage Jenkins - Configure System - Global properties.
you can configure all your Jenkins master using groovy.
I just did the same when we upgrade to Jenkins 2.
here are some links : https://pghalliday.com/jenkins/groovy/sonar/chef/configuration/management/2014/09/21/some-useful-jenkins-groovy-scripts.html
https://github.com/DotCi/jenkinsci-dotci-example/blob/master/configure-dotci.groovy
https://gist.github.com/vrivellino/97954495938e38421ba4504049fd44ea
BTW , you can install your plugins using CLI it will save you time in the future.
and you can create all your jobs using DSL , so all changes will be in github.
if you have specific question , let me know

Jenkings on DCOS - Marathon-plugin missing after install

I added the Marathon plugin to Jenkins through the Jenkins management Web UI. It showed up as a list of available plugins to install. I also downloaded the HPI and added the plugin manually. In both cases, the Marathon option doesn't show up in my pipeline config. I'm following the steps here: https://dcos.io/docs/1.7/usage/tutorials/jenkins/#building-a-docker-image-and-deploying-it-to-marathon
Use version mesosphere/jenkins:3.0.1-2.32.2 in combination with persisting your Jenkins data on NFS. Installation and updates of plugins works for me with this combination.
You should consider missing functionality in older versions of Jenkins in DC/OS as described in this thread: https://github.com/mesosphere/dcos-jenkins-service/issues/105
Do you use a NFS share to persist your Jenkins data? In my experience you can not use DC/OS Jenkins properly without persisting Jenkins' data.

Resources