Re: How to abort a job during it's execution by itself

2018-09-13 Thread Viacheslav Dubrovskyi

Hi

You can use this function for pipeline

@NonCPS
def killthis_job() {
  def jobname = env.JOB_NAME
  def buildnum = env.BUILD_NUMBER.toInteger()

  def job = Jenkins.instance.getItemByFullName(jobname)
  for (build in job.builds) {
    if (!build.isBuilding()) { continue; }
    if (buildnum == build.getNumber().toInteger()) { continue; println 
"equals" }

    currentBuild.result = 'ABORTED'
    error("Old build ${build} working.")
  }
}


11.04.2018 13:33, iostrym пишет:

Is there a possibility to abort a job during it's execution by the job itself.

For instance the job launch a script that do the update from versioning tool 
and if no update are available, then the job is aborted.
This way the job is not stored at all by Jenkins.

Some plugin do already the tool versioning scrutation but we can't use them for 
our specific tool versioning version.

This is why I'm looking for a smart way to abort a build.


--
WBD,
Viacheslav Dubrovskyi


--
You received this message because you are subscribed to the Google Groups "Jenkins 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/39a6142b-0597-c343-391e-125eaca31c31%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to abort a job during it's execution by itself

2018-04-11 Thread iostrym
Is there a possibility to abort a job during it's execution by the job itself.

For instance the job launch a script that do the update from versioning tool 
and if no update are available, then the job is aborted.
This way the job is not stored at all by Jenkins.

Some plugin do already the tool versioning scrutation but we can't use them for 
our specific tool versioning version.

This is why I'm looking for a smart way to abort a build.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/a7a42fdc-bc4a-4b9b-bfed-4b81ea0d87f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.