Git Product home page Git Product logo

useful-jenkins-groovy-init-scripts's Introduction

Useful Jenkins groovy init Scripts

Jenkins allows adding groovy scripts for initialization, which means these scripts will run every time Jenkins starts.

How this works?

The jenkins server automatically looks for groovy.d folder under the home dir of where Jenkins run from e.g. /var/lib/jenkins/groovy.d or /root/.jenkins/groovy.d if running in a container, and any groovy script in folder get executed anytime jenkins starts.

Why use the scripts?

Its a pretty handy way of automating Jenkins installation; lets say you want your CI setup to be automated, like everytime you install your jenkins environment, it should be pre-configured with certain user accounts created, have LDAP configured automatically or some global properties set.

Groovy is an easy way of calling Jenkins base classes of Java without getting to know much of Java itself ;)

What scripts are in this repo?

I have scripts for :

  1. Creating user accounts.
  2. Creating global credentials (for ssh , username/password etc).
  3. Getting the API key of a user ( this is pretty useful because if you use (Jenkins Job Builder )[https://github.com/openstack-infra/jenkins-job-builder.git] for setting up your CI , for the credential .ini file , you will need the API key so why not get it from a groovy script :) )
  4. Setting the global security , either LDAP , or jenkins own database etc.
  5. Setting global authorization matrix for groups like anonymous, authenticated or any specific user.
  6. Get a credential ID of a global credential, again extremely useful when you use Jenkins Job BUilder and in git SCM, you need to specify (Credential ID of ssh key for git to use in cloning some private repos)[http://docs.openstack.org/infra/jenkins-job-builder/scm.html], this script will do it for you .

Cheers :)

useful-jenkins-groovy-init-scripts's People

Contributors

hayderimran7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

useful-jenkins-groovy-init-scripts's Issues

Groovy script runs but no changes are performed

Dear hayderimran7,
This groovy script runs successfully (LDAP) but no changes are done to Jenkins config.xml file thus no changes are applied (default is Jenkins database and whoever is logged can do anything).
Is there anything else that needs to happen after the groovy script runs? Is the passcode cleartext or hash?
I'd appreciate if you could clarify. I imagine the groovy script would cause changes to the config.xml file as it happens if I configure it via Web UI.
Thanks in advance!

Issue with User add Groovy script for Jenkins

Hi Hayderimran, I tried below script, It runs without errors but users are not getting added to Jenkins, I am not running it from init.groovy.d , I dont need the script to run every time Jenkins is started. I am using 2 files user_add.groovy and Users.txt with user name, email, passwd and full name info.

`
Users.txt

user_add.txt

`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.