GroovyAxis

Skip to end of metadata
Go to start of metadata

Plugin Information

Plugin ID groovyaxis Changes In Latest Release
Since Latest Release
Latest Release
Latest Release Date
Required Core
Dependencies
0.3 (archives)
Jan 04, 2013
1.472
Source Code
Issue Tracking
Pull Requests
Maintainer(s)
GitHub
Open Issues
Pull Requests
Emanuele Zattin (id: emanuelez)
Usage Installations 2014-May 237
2014-Jun 247
2014-Jul 260
2014-Aug 245
2014-Sep 261
2014-Oct 295
2014-Nov 295
2014-Dec 289
2015-Jan 301
2015-Feb 305
2015-Mar 319
2015-Apr 326

Jenkins Groovy Axis Plugin

Description

This plugin allows to have scriptable axes for Matrix Jobs. Groovy is the scripting language being used.

The script will have to return a list of strings and each of the strings will be an element of the axis.

If the script does not return a list of strings then

[default]

will be returned instead.

Examples

Define an axis with three values:

return [ "Axis1", "Axis2", "Axis3" ]

Define the same axis programmatically:

def result = []
(1..3).each {
   result += "Axis"+it
}
return result

Define an axis whose values are the files in the root directory:

def dir = new File('/')
def result = []
dir.eachFile {
   if (it.isFile()) {
      result += it.canonicalPath
   }
}

return result

Screenshot

Labels

plugin-misc plugin-misc Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Sep 22, 2011

    whtstar2 says:

    Is it possible to include environment variables in the groovy script? I'd like t...

    Is it possible to include environment variables in the groovy script? I'd like things such as file paths to be dynamic...

    1. Nov 13, 2011

      erikzaadi says:

      Just use : System.getenv("YOUR_ENV")

      Just use : System.getenv("YOUR_ENV")

      1. Jan 18, 2013

        ivan_zolotuhin says:

        Hi, I am trying to create axis to deploy some content to choosen to all selecte...

        Hi,

        I am trying to create axis to deploy some content to choosen to all selected environments.

        The idea is to setup "This build is parameterized" -> create booleans: QA_SERVER1, QA_SERVER2, QA_SERVER3

        And if user select for example QA_SERVER1 & QA_SERVER3 it should execute only for this servers.

        I wrote script (not only , but to understand my logic), but it not working.

        How should I rewrite it to access custom booleans?

        import hudson.model.*
        def result = []
        
        if ( System.getEnv('QA_SERVER1') == true ) {
        result += 'qaserver1.domain.com'
        }
        if ( System.getEnv('QA_SERVER2') == true ) {
        result += 'qaserver2.domain.com'
        }
        if ( System.getEnv('QA_SERVER3') == true ) {
        result += 'qaserver3.domain.com'
        }
        return result
        
  2. May 21, 2012

    mene says:

    Ouch, this was not as dynamic as I hoped. The groovy script doesn't seem to be r...

    Ouch, this was not as dynamic as I hoped. The groovy script doesn't seem to be run for each build. It is only run when pressing Save/Apply in the project configuration. Could that be changed somehow? I have matrix values stored in files and I want them to be reread for every build.

    1. May 24, 2012

      Emanuele Zattin says:

      There's a pull request in Jenkins core to address this issue.

      There's a pull request in Jenkins core to address this issue.

      1. Jun 26, 2012

        Markus Juuti says:

        I upgraded Jenkins to 1.472, which according to changelog has this feature imple...

        I upgraded Jenkins to 1.472, which according to changelog has this feature implemented. Do I need to modify now something to actually get it working, as my axis definition updates still only when I apply/save job settings.

        My axis is simple groovy script reading axis definition from a text file on web server as follows;

        def url = "http://www.domain.com/testsets.txt".toURL()
        def testsets = []
        url.withReader { reader ->
          reader.eachLine { line ->
            testsets += line
          }
        }
        return testsets
        
  3. Sep 28, 2012

    bjschuma says:

    Is it possible to include build parameters in the script?  For example, I c...

    Is it possible to include build parameters in the script?  For example, I could have another job pass in a list of Linux .config files and build a kernel for each.

  4. Oct 30, 2012

    nickolay_martinov says:

    I'm trying to trigger matrix jobs on all nodes of particular type. Since there a...

    I'm trying to trigger matrix jobs on all nodes of particular type. Since there are lots of configured nodes and some of them can be offline the plugin seems to be a natural choice. However, the things doesnt seem to work. The expression for axis values is

    def result = []
    jenkins.model.Jenkins.instance.nodes.each {
        if (it.toComputer().online && it.assignedLabels.contains(new hudson.model.labels.LabelAtom("linux"))) {
            result += it.name
        }
    }
    return result
    

    It correctly determines node names: [ superfrog1, pintov1, pintov2, swtsscg, gdrcw, pintov4, pecanv6 ]

    However, when build is executed then things go wrong as Jenkins doesnt seems to be using axis values at all:Building remotely on swtsscg in workspace /ci/workspace/test/node/superfrog1
    [superfrog1] $ /bin/sh -xe /tmp/hudson5253422839681441452.sh
    Label is superfrog1
    Executing on swtsscg

    So while axis label was superfrog1 build was executed on node stwsscg. Any suggestions?

  5. Mar 25, 2013

    ernstp says:

    Here's how to do it with build parameters, according to https://github.com/jenki...

    Here's how to do it with build parameters, according to https://github.com/jenkinsci/groovyaxis-plugin/commit/945518d9c2b35376f9ddf8b72e71a7aeec65b9e8 :

    def value = ""
    if (context != null) {
      def resolver = context.build.buildVariableResolver
      value = resolver.resolve("AXISVALUES")
    }
    return value.split() as List
  6. Feb 12, 2014

    cosmo says:

    I see the same behavior as Nickolay.  Jobs with the discovered labels are e...

    I see the same behavior as Nickolay.  Jobs with the discovered labels are executed, however they actually run on the wrong nodes.  Has anyone looked into it?

    I would love to get this plugin working!

    1. Feb 12, 2014

      cosmo says:

      This change fixes it for me (extend LabelAxis instead of Axis).  I made my ...

      This change fixes it for me (extend LabelAxis instead of Axis).  I made my own fork of this plugin called GroovyLabelAxis which solves it nicely.  Including ernstp's parameters option this givesreally nice functionality of choosing labels for the axis at job runtime

      public class GroovyLabelAxis extends LabelAxis {
      ...
      
      1. Mar 19, 2014

        roosto says:

        Cosmo, Have you published this fix anywhere? I am running into the same problem...

        Cosmo,

        Have you published this fix anywhere? I am running into the same problem

        Thanks.

  7. Feb 11

    tch says:

    I configure so that the Axis amount depended on the parameter build. But there i...

    I configure so that the Axis amount depended on the parameter build. But there is a problem:

    let's build A has started 20 Axis and the next build  B- 10. At the matrix A will be showed only 10 Axis icons and links. Is it possible to display the Axis as much as was used in the build?

    1. Feb 12

      nickolay_martinov says:

      You can spawn full matrix and then selectively skip configurations you are not i...

      You can spawn full matrix and then selectively skip configurations you are not interested in. You can colorize "skipped" builds and even add badges and explanations to them. Decision to skip is just a first step in the build. Could be groovy or shell. Groovy postbuild plugin can be used to check if build was skipped  and colorize result for this configuration.