Giter VIP home page Giter VIP logo

text-finder-plugin's Introduction

Text Finder Plugin

Introduction

This plugin lets you search for some text using regular expressions in a set of files or the console log. Based on the outcome, you can downgrade the build result to UNSTABLE, FAILURE, NOT_BUILT, or ABORTED.

For example, you can search for the string failure in a set of log files. If a match is found, you can downgrade the build result from SUCCESS to FAILURE. This is handy when you have some tools in your build chain that do not properly set the exit code.

Getting started

The basic Pipeline syntax is as follows:

findText(textFinders: [textFinder(regexp: '<regular expression>', fileSet: '<file set>')])

The regular expression uses the syntax supported by the Java Pattern class. The file set specifies the path to the files to search, relative to the workspace root. This can use wildcards, like logs/*//*.txt. See the documentation for the @includes attribute of the Ant FileSet type for details.

To also check the console log, use the following syntax:

findText(textFinders: [textFinder(regexp: '<regular expression>', fileSet: '<file set>', alsoCheckConsoleOutput: true)])

If you just want to check the console log, you can omit the file set:

findText(textFinders: [textFinder(regexp: '<regular expression>', alsoCheckConsoleOutput: true)])

To downgrade the build result, use the following syntax:

findText(textFinders: [textFinder([...], buildResult: 'UNSTABLE')])

If a match is found, the build result will be set to this value.

ℹī¸
The build result can only get worse, so you cannot change the result to SUCCESS if the current result is UNSTABLE or worse.

Whether or not a build is downgraded depends on its change condition. The default change condition is MATCH_FOUND, which downgrades the build result if a match is found. To downgrade the build result if a match is not found, set the change condition to MATCH_NOT_FOUND:

findText(textFinders: [textFinder([...], changeCondition: 'MATCH_NOT_FOUND', buildResult: 'UNSTABLE')])

To search for multiple regular expressions, use the following syntax:

findText(textFinders: [
  textFinder(regexp: '<regular expression 1>', [...]),
  textFinder(regexp: '<regular expression 2>', [...]),
  textFinder(regexp: '<regular expression 3>', [...])
])

Freestyle jobs

This plugin provides Job DSL support for Freestyle jobs using the Dynamic DSL. For example:

job('example') {
  publishers {
    findText {
      textFinders {
        textFinder {
          regexp '<regular expression>'
          fileSet '<file set>'
          changeCondition '<MATCH_FOUND or MATCH_NOT_FOUND>'
          alsoCheckConsoleOutput true
          buildResult 'UNSTABLE'
        }
      }
    }
  }
}

To search for multiple regular expressions, use the following syntax:

job('example') {
  publishers {
    findText {
      textFinders {
        textFinder {
          regexp '<regular expression 1>'
          [...]
        }
        textFinder {
          regexp '<regular expression 2>'
          [...]
        }
        textFinder {
          regexp '<regular expression 3>'
          [...]
        }
      }
    }
  }
}

Issues

Report issues and enhancements in the Jenkins issue tracker. Use the text-finder-plugin component in the JENKINS project.

Contributing

Refer to our contribution guidelines.

text-finder-plugin's People

Contributors

alanharder avatar basil avatar dependabot-preview[bot] avatar dependabot[bot] avatar hazim1093 avatar jglick avatar jlosito avatar markewaite avatar mattiasbpersson avatar mawinter69 avatar ndeloof avatar sparkoo avatar timja-bot avatar tyuki39 avatar ymougenel avatar zhaoying818 avatar

Stargazers

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

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.