Coder Social home page Coder Social logo

jenkins-scripting's Introduction

Jenkins scripting

Build Status

This repository contains a Maven project that can help you to ease developing and learning of Jenkins groovy scripts.

This Maven project contains steps to compile groovy scripts and send them for execution to an instance of Jenkins. This allows to automate such manual steps, that you do while developing or learning Jenkins scripts, as copy-pasting from some text editor to Jenkins script console (https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console) and pushing "run" button.

Additionally, if you would like to develop your jenkins groovy scripts or explore Jenkins API (http://javadoc.jenkins-ci.org/) with support of code completion or type inference features, open this Maven project in any modern IDE that supports Maven and Groovy.

Usage

  1. Adjust Jenkins connectivity and credentials settings

    • Directly in the pom.xml

      ...
      <jenkins.url>CHANGE_ME</jenkins.url>
      <jenkins.user>CHANGE_ME</jenkins.user>
      <jenkins.token>CHANGE_ME</jenkins.token>
      ...
    • Or override the properties with CLI options for Maven

      mvn -Djenkins.url=<url> -Djenins.user=<user> -Djenkins.token=<token> ....
  2. Check you are able to execute jenkins scripts

    $ mvn clean test
  3. Add dependencies specific to your jenkins installation to the pom.xml

    // Put the script to http://<jenkins-controller>/manage/script to generate Maven dependencies declarations.
    StringBuilder reply = new StringBuilder()
    Jenkins.instance.pluginManager.plugins.each {
        def attributes = it.getManifest().getMainAttributes()
        reply << "<dependency>\n"
        reply << "  <groupId>${attributes.getValue('Group-Id')}</groupId>\n"
        reply << "  <artifactId>${attributes.getValue('Short-Name')}</artifactId>\n"
        reply << "  <version>${attributes.getValue('Plugin-Version')}</version>\n"
        reply << '</dependency>\n'
    }
    reply.toString()
  4. Code in src/main/groovy/jenkins-script.groovy If Jenkins core API is not enough for your needs, add dependencies for that or this jenkins plugin to the pom file.

  5. Try the script

    $ mvn test
  6. Return to coding

jenkins-scripting's People

Contributors

alexanderzobkov avatar dependabot-preview[bot] avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.