1

I'm new to Jenkins and have the follwing task. I'm trying to run a job when a condition is met, this condition will come from the console log.

There is a method, in a first job, that outputs to console "Yes" or "No". I need to parse this console output, get the value and if it is "Yes", I want to start the second job, if "No", don't start it.

I've tried to search for jenkins plugins but there is nothing that fits my task or I just didn't find it.

Can anyone give me advice or solutions:

  1. To parse console output and get my param "Yes" or "No"
  2. To run the second job if param is "Yes"

Thanks!

Lætitia
  • 1,388
  • 1
  • 20
  • 30

1 Answers1

0

You can trigger a job using the Remote access API

Remote API can be used to do things like these:

  1. retrieve information from Jenkins for programmatic consumption.

  2. trigger a new build

  3. create/copy jobs

You could have a groovy step in your first job which follows this approach to trigger a job on your condition

def list = manager.build.logFile.readLines()
def JobCount = list.count {it.startsWith("====") && it.contains("COMPLETE")} 

And to call an end point in groovy this is all you need

def html = "http://google.com".toURL().text
Community
  • 1
  • 1
KeepCalmAndCarryOn
  • 8,817
  • 2
  • 32
  • 47