Git Product home page Git Product logo

jenkins-scripts's Introduction

jenkins-scripts

Groovy scripts for configuring Jenkins via Ansible.

  • Add a folder
  • Add a basic Job (Jenkins calls these projects ... I don't)
  • Add a multibranch pipeline job.
  • Add a job from XML file (This lets you put it in a folder which the Ansible jenkins_job module does not)
  • Harden a Jenkins server by disabling all the insecure stuff that a default instalation complains about.

Jenkins has various other ways to achive the above (JobDSL plugin, Python Jenkins API bindings), but they all have shortcommings so I prefer to use the Jenkins Java API directly. It's pitty there is no documentation for this approach because it's always possible to configure anything you find in the (horrible) Jenkins GUI because that GUI uses the same APIs.

These scripts were used with the jenkins_script Ansible module:

http://docs.ansible.com/ansible/latest/jenkins_script_module.html

Example usage with Ansible:

- name: Add Jenkins folder per environment
  jenkins_script:
    script: "{{ lookup('file', 'templates/add-folder.groovy') }}"
    args:
      folderName: "{{ job.key }}"
    url: "{{ jenkins_url }}"
    user: "{{ jenkins_admin_username }}"
    password: "{{ jenkins_admin_password }}"
  with_dict: "{{ example_environments }}"
  loop_control:
    loop_var: job
    label: "{{ job.key }}"

- name: Add deployment pipeline
  jenkins_script:
    script: "{{ lookup('file', 'templates/add-multibranch-pipeline-job.groovy') }}"
    args:
      folderName: "{{ job.key }}"
      jobName: example-deploy
      jobScript: jenkins/example-deploy.groovy
      gitRepo: "{{ example_environment_repos.example.repo }}"
      gitRepoName: example
      credentialsId: "{{ example_users.bot.id }}"
    url: "{{ jenkins_url }}"
    user: "{{ jenkins_admin_username }}"
    password: "{{ jenkins_admin_password }}"
  with_dict: "{{ example_environments }}"
  loop_control:
    loop_var: job
    label: "{{ job.key }}"

jenkins-scripts's People

Contributors

peterjenkins1 avatar

Watchers

 avatar

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.