public class BuildService extends Object
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_FIRST_CHECK_DELAY
Default value of
firstCheckDelay |
static long |
DEFAULT_POLL_PERIOD
Default value of
pollPeriod |
Constructor and Description |
---|
BuildService(long firstCheckDelay,
long pollPeriod) |
Modifier and Type | Method and Description |
---|---|
BuildTriggerStatus |
build(com.offbytwo.jenkins.JenkinsServer jenkinsServer,
String jobName,
long timeout)
See the documentation in
DiggerClient.build(String, long) |
com.offbytwo.jenkins.model.BuildWithDetails |
cancelBuild(com.offbytwo.jenkins.JenkinsServer jenkins,
String jobName,
int buildNumber)
Cancel a build
|
com.offbytwo.jenkins.model.Build |
getBuild(com.offbytwo.jenkins.JenkinsServer jenkins,
String jobName,
int buildNumber)
Retrieve a build from a specific job
|
com.offbytwo.jenkins.model.BuildWithDetails |
getBuildDetails(com.offbytwo.jenkins.JenkinsServer jenkins,
String jobName,
int buildNumber)
Get the build details of a job
|
List<com.offbytwo.jenkins.model.BuildWithDetails> |
getBuildHistory(com.offbytwo.jenkins.JenkinsServer jenkins,
String jobName)
Returns the build history for a job.
|
String |
getBuildLogs(com.offbytwo.jenkins.JenkinsServer jenkins,
String jobName,
int buildNumber)
Get build logs for specific job and build number
|
BuildTriggerStatus |
pollBuild(com.offbytwo.jenkins.JenkinsServer jenkinsServer,
String jobName,
com.offbytwo.jenkins.model.QueueReference queueReference,
long timeout,
Map<String,String> params)
See the documentation in
DiggerClient.build(String, long, Map) |
void |
streamBuildLogs(com.offbytwo.jenkins.JenkinsServer jenkins,
String jobName,
int buildNumber,
LogStreamingOptions options)
Start streaming the logs of the given build.
|
BuildTriggerStatus |
triggerBuild(com.offbytwo.jenkins.JenkinsServer jenkinsServer,
String jobName,
Map<String,String> params) |
public static final long DEFAULT_FIRST_CHECK_DELAY
firstCheckDelay
public static final long DEFAULT_POLL_PERIOD
pollPeriod
public BuildService(long firstCheckDelay, long pollPeriod)
firstCheckDelay
- how long should we wait (in milliseconds) before we start checking the queue item statuspollPeriod
- how long should we wait (in milliseconds) before checking the queue item status for next timepublic String getBuildLogs(com.offbytwo.jenkins.JenkinsServer jenkins, String jobName, int buildNumber) throws DiggerClientException, IOException
jobName
- name of the jobbuildNumber
- job build numberDiggerClientException
- when problem with fetching artifacts from jenkinsIOException
public List<com.offbytwo.jenkins.model.BuildWithDetails> getBuildHistory(com.offbytwo.jenkins.JenkinsServer jenkins, String jobName) throws DiggerClientException
JobWithDetails.getBuilds()
it will return max 100 most-recent builds.
Please note that this approach will take some time since we first fetch the builds in 1 call, then fetch build details in 1 call per build.
jenkins
- Jenkins server clientjobName
- name of the jobDiggerClientException
- if connection problems occurpublic BuildTriggerStatus triggerBuild(com.offbytwo.jenkins.JenkinsServer jenkinsServer, String jobName, Map<String,String> params) throws IOException, InterruptedException
jenkinsServer
- Jenkins server clientjobName
- name of the jobparams
- build parameters to override defaults in the jobIOException
- if connection problems occur during connecting to JenkinsInterruptedException
- if a problem occurs during sleeping between checkspublic BuildTriggerStatus pollBuild(com.offbytwo.jenkins.JenkinsServer jenkinsServer, String jobName, com.offbytwo.jenkins.model.QueueReference queueReference, long timeout, Map<String,String> params) throws IOException, InterruptedException
DiggerClient.build(String, long, Map)
jenkinsServer
- Jenkins server clientjobName
- name of the jobtimeout
- timeoutparams
- build parameters to override defaults in the jobIOException
- if connection problems occur during connecting to JenkinsInterruptedException
- if a problem occurs during sleeping between checksDiggerClient.build(String, long, Map)
public BuildTriggerStatus build(com.offbytwo.jenkins.JenkinsServer jenkinsServer, String jobName, long timeout) throws IOException, InterruptedException
DiggerClient.build(String, long)
jenkinsServer
- Jenkins server clientjobName
- name of the jobtimeout
- timeoutIOException
- if connection problems occur during connecting to JenkinsInterruptedException
- if a problem occurs during sleeping between checksDiggerClient.build(String, long)
public com.offbytwo.jenkins.model.Build getBuild(com.offbytwo.jenkins.JenkinsServer jenkins, String jobName, int buildNumber) throws DiggerClientException
jenkins
- the jenkins instancejobName
- the name of the jobbuildNumber
- the build numberBuild
DiggerClientException
public com.offbytwo.jenkins.model.BuildWithDetails getBuildDetails(com.offbytwo.jenkins.JenkinsServer jenkins, String jobName, int buildNumber) throws DiggerClientException, IOException
jenkins
- the jenkins instancejobName
- the name of the jobbuildNumber
- the build numberBuildWithDetails
DiggerClientException
IOException
public com.offbytwo.jenkins.model.BuildWithDetails cancelBuild(com.offbytwo.jenkins.JenkinsServer jenkins, String jobName, int buildNumber) throws DiggerClientException, IOException
jenkins
- the jenkins instancejobName
- the name of the jobbuildNumber
- the build numberBuildWithDetails
DiggerClientException
IOException
public void streamBuildLogs(com.offbytwo.jenkins.JenkinsServer jenkins, String jobName, int buildNumber, LogStreamingOptions options) throws DiggerClientException, IOException, InterruptedException
DiggerClient.streamLogs(String, int, LogStreamingOptions)
Copyright © 2017 JBoss by Red Hat. All Rights Reserved.