GithubHelp home page GithubHelp logo

ttyniwa / parameterized-scheduler-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jenkinsci/parameterized-scheduler-plugin

0.0 0.0 0.0 144 KB

A Jenkins Plugin to support setting parameters in the build schedule

License: MIT License

Java 96.55% HTML 3.45%

parameterized-scheduler-plugin's Introduction

Parameterized Scheduler

A Jenkins Plugin to support setting parameters in the build schedule. Using multiple cron lines each ending with a % and some name=value pairs you can schedule your parameterized build to run with different parameters at different times. It may turn out that this improvement request JENKINS-16352 will be implemented in Jenkins core. Then this plugin will no longer be needed. My first thought is to try it out as a plugin. This plugin now supports declarative Jenkins pipelines. See configuration example below.

Installation

Clone or fork to build the .hpi yourself (mvn package) or download the .hpi from my release. Then follow the Jenkins Plugin installation instructions

Configuration

After you save your project with some parameters (yes, save, then go back into the config page) you will see

Build periodically with parameters

in the Build Triggers section as shown here:

Parameterized Schedular Config

Configuration Example

The cron line before the % symbol is processed the same as the jenkins core Build periodically Schedule. Leave a space. Put in a %. Then add the name=value pairs you need for your project build parameters.

The idea was born from the need to use a different environment. To use a different TestNG configuration xml. In this example the env parameter will be set to int during the build triggered at 15 after each hour. Then env will be qa when the build runs at half past.

  #lets run against the integration environment at 15 past the hour
  15 * * * * % env=int
  #run QA too
  30 * * * % env=qa

Yes, of course you can set multiple parameters. Lets say you have three parameters:

  • furniture
  • color
  • name (with a default of fred)

Then you might want a schedule like the following:

  # leave spaces where you want them around the parameters. They'll be trimmed.
  # we let the build run with the default name
  5 * * * * % furniture=chair;color=black
  # now, let's override that default name and use Mr. Rubble.
  10 * * * * % furniture=desk; color=yellow; name=barney

Declarative Pipeline Configuration Example

The parameterized cron trigger can be specified using the key parameterizedSpecification under the parameterizedCron under the triggers directive. The built in cron trigger is still available and is independent of parameterizedCron.

Example:

pipeline {
    agent any
    parameters {
      string(name: 'PLANET', defaultValue: 'Earth', description: 'Which planet are we on?')
      string(name: 'GREETING', defaultValue: 'Hello', description: 'How shall we greet?')
    }
    triggers {
        parameterizedCron('''
            # leave spaces where you want them around the parameters. They'll be trimmed.
            # we let the build run with the default name
            */2 * * * * %GREETING=Hola;PLANET=Pluto
            */3 * * * * %PLANET=Mars
        ''')
    }
    stages {
        stage('Example') {
            steps {
                echo "${params.GREETING} ${params.PLANET}"
                script { currentBuild.description = "${params.GREETING} ${params.PLANET}" }
            }
        }
    }
}

Example Output in Jenkins

Example Output in Jenkins

parameterized-scheduler-plugin's People

Contributors

batmat avatar brian-bates avatar colbynh avatar colourmeamused avatar commanda avatar dependabot-preview[bot] avatar froblesmartin avatar jonahgraham avatar jwmach1 avatar krrrr38 avatar patbos avatar peppelan avatar reftel avatar yogeek 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.