public class JenkinsServer extends Object
Constructor and Description |
---|
JenkinsServer(JenkinsHttpClient client)
Create a new Jenkins server directly from an HTTP client (ADVANCED)
|
JenkinsServer(URI serverUri)
Create a new Jenkins server reference given only the server address
|
JenkinsServer(URI serverUri,
String username,
String passwordOrToken)
Create a new Jenkins server reference given the address and credentials
|
Modifier and Type | Method and Description |
---|---|
void |
addStringParam(String jobName,
String name,
String description,
String defaultValue) |
void |
cancelQuietDown()
Cancels the Quiet Down (Prepare for shutdown) message
|
void |
createCredential(Credential credential,
boolean crumbFlag)
Create the given credential
|
void |
createFolder(FolderJob folder,
String jobName)
Create a job on the server (in the given folder)
|
void |
createFolder(FolderJob folder,
String jobName,
Boolean crumbFlag)
Create a job on the server (in the given folder)
|
void |
createFolder(String folderName)
Create a folder on the server (in the root)
|
void |
createFolder(String folderName,
Boolean crumbFlag)
Create a folder on the server (in the root)
|
void |
createJob(FolderJob folder,
String jobName,
String jobXml)
Create a job on the server using the provided xml and in the provided
folder
|
void |
createJob(FolderJob folder,
String jobName,
String jobXml,
Boolean crumbFlag)
Create a job on the server using the provided xml and in the provided
folder
|
void |
createJob(String jobName,
String jobXml)
Create a job on the server using the provided xml
|
void |
createJob(String jobName,
String jobXml,
Boolean crumbFlag)
Create a job on the server using the provided xml
|
void |
createView(FolderJob folder,
String viewName,
String viewXml)
Create a view on the server using the provided xml and in the provided
folder.
|
void |
createView(FolderJob folder,
String viewName,
String viewXml,
Boolean crumbFlag)
Create a view on the server using the provided xml and in the provided
folder.
|
void |
createView(String viewName,
String viewXml)
Create a view on the server using the provided xml
|
void |
createView(String viewName,
String viewXml,
Boolean crumbFlag)
Create a view on the server using the provided xml.
|
void |
deleteCredential(String credentialId,
boolean crumbFlag)
Delete an existing credential
|
void |
deleteJob(FolderJob folder,
String jobName)
Delete a job from Jenkins within a folder.
|
void |
deleteJob(FolderJob folder,
String jobName,
boolean crumbFlag)
Delete a job from Jenkins within a folder.
|
void |
deleteJob(String jobName)
Delete a job from jenkins
|
void |
deleteJob(String jobName,
boolean crumbFlag)
Delete a job from Jenkins.
|
void |
disableJob(String jobName)
Disable a job from jenkins
|
void |
disableJob(String jobName,
boolean crumbFlag)
Disable a job from Jenkins.
|
void |
enableJob(String jobName)
Enable a job from jenkins
|
void |
enableJob(String jobName,
boolean crumbFlag)
Enable a job from Jenkins.
|
Plugin |
findPluginWithName(String pluginShortName)
Find a plugin that matches the given short name
|
Build |
getBuild(QueueItem q) |
Map<String,Computer> |
getComputers()
Get a list of all the computers on the server (at the summary level)
|
ComputerSet |
getComputerSet()
The ComputerSet class will give informations like
ComputerSet.getBusyExecutors() or the
ComputerSet.getTotalExecutors() . |
com.google.common.base.Optional<FolderJob> |
getFolderJob(Job job) |
JobWithDetails |
getJob(FolderJob folder,
String jobName)
Get a single Job from the given folder.
|
JobWithDetails |
getJob(String jobName)
Get a single Job from the server.
|
Map<String,Job> |
getJobs()
Get a list of all the defined jobs on the server (at the summary level)
|
Map<String,Job> |
getJobs(FolderJob folder)
Get a list of all the defined jobs on the server (in the given folder)
|
Map<String,Job> |
getJobs(FolderJob folder,
String view)
Get a list of all the defined jobs on the server (at the specified view
level and in the specified folder)
|
Map<String,Job> |
getJobs(String view)
Get a list of all the defined jobs on the server (at the specified view
level)
|
String |
getJobXml(FolderJob folder,
String jobName)
Get the xml description of an existing job.
|
String |
getJobXml(String jobName)
Get the xml description of an existing job
|
LabelWithDetails |
getLabel(String labelName)
Get the description of an existing Label
|
MavenJobWithDetails |
getMavenJob(FolderJob folder,
String jobName) |
MavenJobWithDetails |
getMavenJob(String jobName) |
PluginManager |
getPluginManager()
This will give you back the
PluginManager . |
Queue |
getQueue() |
QueueItem |
getQueueItem(QueueReference ref) |
JenkinsVersion |
getVersion() |
View |
getView(FolderJob folder,
String name)
Get a single view object from the given folder
|
View |
getView(String name)
Get a single view object from the server
|
Map<String,View> |
getViews()
Get a list of all the defined views on the server (at the summary level)
|
Map<String,View> |
getViews(FolderJob folder)
Get a list of all the defined views on the server (at the summary level
and in the given folder)
|
boolean |
isRunning()
Get the current status of the Jenkins end-point by pinging it.
|
Map<String,Credential> |
listCredentials()
List the credentials from the Jenkins server.
|
void |
quietDown()
Sends the Quiet Down (Prepare for shutdown) message
|
void |
renameJob(FolderJob folder,
String oldJobName,
String newJobName)
Rename a job
|
void |
renameJob(FolderJob folder,
String oldJobName,
String newJobName,
Boolean crumbFlag)
Rename a job
|
void |
renameJob(String oldJobName,
String newJobName)
Rename a job
|
void |
renameJob(String oldJobName,
String newJobName,
Boolean crumbFlag)
Rename a job
|
String |
runScript(String script)
Runs the provided groovy script on the server and returns the result.
|
String |
runScript(String script,
boolean crumbFlag)
Runs the provided groovy script on the server and returns the result.
|
void |
updateCredential(String credentialId,
Credential credential,
boolean crumbFlag)
Update an existing credential
|
void |
updateJob(FolderJob folder,
String jobName,
String jobXml,
boolean crumbFlag)
Update the xml description of an existing job
|
void |
updateJob(String jobName,
String jobXml)
Update the xml description of an existing job
|
void |
updateJob(String jobName,
String jobXml,
boolean crumbFlag)
Update the xml description of an existing job
|
void |
updateView(FolderJob folder,
String viewName,
String viewXml) |
void |
updateView(FolderJob folder,
String viewName,
String viewXml,
boolean crumbFlag) |
void |
updateView(String viewName,
String viewXml)
Update the xml description of an existing view
|
void |
updateView(String viewName,
String viewXml,
boolean crumbFlag) |
public JenkinsServer(URI serverUri)
serverUri
- address of jenkins server (ex.
http://localhost:8080/jenkins)public JenkinsServer(URI serverUri, String username, String passwordOrToken)
serverUri
- address of jenkins server (ex.
http://localhost:8080/jenkins)username
- username to use when connectingpasswordOrToken
- password (not recommended) or token (recommended)public JenkinsServer(JenkinsHttpClient client)
client
- Specialized client to use.public boolean isRunning()
public JenkinsVersion getVersion()
JenkinsVersion
public Map<String,Job> getJobs() throws IOException
IOException
- in case of an error.public Map<String,Job> getJobs(FolderJob folder) throws IOException
folder
- FolderJob
IOException
- in case of an error.public Map<String,Job> getJobs(String view) throws IOException
view
- The view to get jobs from.IOException
- in case of an error.public Map<String,Job> getJobs(FolderJob folder, String view) throws IOException
folder
- FolderJob
view
- The view to use.IOException
- in case of an error.public Map<String,View> getViews() throws IOException
IOException
- in case of an error.public Map<String,View> getViews(FolderJob folder) throws IOException
folder
- FolderJob
IOException
- in case of an error.public View getView(String name) throws IOException
name
- name of the view in JenkinsIOException
- in case of an error.public View getView(FolderJob folder, String name) throws IOException
folder
- The name of the folder.name
- name of the view in JenkinsIOException
- in case of an error.public JobWithDetails getJob(String jobName) throws IOException
jobName
- name of the job to get details of.IOException
- in case of an error.public JobWithDetails getJob(FolderJob folder, String jobName) throws IOException
folder
- FolderJob
jobName
- name of the job to get details of.IOException
- in case of an error.public MavenJobWithDetails getMavenJob(String jobName) throws IOException
IOException
public MavenJobWithDetails getMavenJob(FolderJob folder, String jobName) throws IOException
IOException
public com.google.common.base.Optional<FolderJob> getFolderJob(Job job) throws IOException
IOException
public void createJob(String jobName, String jobXml) throws IOException
jobName
- name of the job to be created.jobXml
- the config.xml
which should be used to create
the job.IOException
- in case of an error.public void createJob(String jobName, String jobXml, Boolean crumbFlag) throws IOException
jobName
- name of the job to be created.jobXml
- the config.xml
which should be used to create
the job.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- in case of an error.public void createJob(FolderJob folder, String jobName, String jobXml) throws IOException
folder
- FolderJob
jobName
- name of the job to be created.jobXml
- the config.xml
which should be used to create
the job.IOException
- in case of an error.public void createJob(FolderJob folder, String jobName, String jobXml, Boolean crumbFlag) throws IOException
folder
- FolderJob
jobName
- name of the job to be created.jobXml
- the config.xml
which should be used to create
the job.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- in case of an error.public void createView(String viewName, String viewXml) throws IOException
viewName
- name of the view to be created.viewXml
- The configuration for the view.IOException
- in case of an error.public void createView(String viewName, String viewXml, Boolean crumbFlag) throws IOException
viewName
- name of the view to be created.viewXml
- The configuration for the view.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- in case of an error.public void createView(FolderJob folder, String viewName, String viewXml) throws IOException
folder
- FolderJob
viewName
- name of the view to be created.viewXml
- The configuration for the view.IOException
- in case of an error.public void createView(FolderJob folder, String viewName, String viewXml, Boolean crumbFlag) throws IOException
folder
- the folder.viewName
- the view name.viewXml
- the view xml.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- in case of an error.public void createFolder(String folderName) throws IOException
folderName
- name of the folder.IOException
- in case of an error.public void createFolder(String folderName, Boolean crumbFlag) throws IOException
folderName
- name of the folder.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- in case of an error.public void createFolder(FolderJob folder, String jobName) throws IOException
folder
- FolderJob
jobName
- name of the job.IOException
- in case of an error.public void createFolder(FolderJob folder, String jobName, Boolean crumbFlag) throws IOException
folder
- FolderJob
jobName
- name of the job.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- in case of an error.public String getJobXml(String jobName) throws IOException
jobName
- name of the job.IOException
- in case of an error.public String getJobXml(FolderJob folder, String jobName) throws IOException
jobName
- name of the job.folder
- FolderJob
IOException
- in case of an error.public LabelWithDetails getLabel(String labelName) throws IOException
labelName
- name of the label.LabelWithDetails
IOException
- in case of an error.public Map<String,Computer> getComputers() throws IOException
IOException
- in case of an error.public ComputerSet getComputerSet() throws IOException
ComputerSet.getBusyExecutors()
or the
ComputerSet.getTotalExecutors()
.ComputerSet
IOException
- in case of an error.public PluginManager getPluginManager() throws IOException
PluginManager
.PluginManager
IOException
- in case of a failure.public void updateView(String viewName, String viewXml) throws IOException
viewName
- name of the view.viewXml
- the view configuration.IOException
- in case of an error.IOException
- in case of an error.public void updateView(String viewName, String viewXml, boolean crumbFlag) throws IOException
IOException
public void updateView(FolderJob folder, String viewName, String viewXml) throws IOException
IOException
public void updateView(FolderJob folder, String viewName, String viewXml, boolean crumbFlag) throws IOException
IOException
public void updateJob(String jobName, String jobXml) throws IOException
jobName
- name of the job to be updated.jobXml
- the configuration to be used for updating.IOException
- in case of an error.public void updateJob(String jobName, String jobXml, boolean crumbFlag) throws IOException
jobName
- name of the job to be updated.jobXml
- the configuration to be used for updating.crumbFlag
- true/false.IOException
- in case of an error.public void updateJob(FolderJob folder, String jobName, String jobXml, boolean crumbFlag) throws IOException
folder
- the folder.jobName
- the name of the job.jobXml
- the job xml configuration.crumbFlag
- true/false.IOException
- in case of an error.public void addStringParam(String jobName, String name, String description, String defaultValue) throws IOException, JAXBException, org.dom4j.DocumentException
jobName
- name of the job.name
- name of the parameter.description
- of the parameters.defaultValue
- the defaultValue for the parameters.IOException
- in case of an error.JAXBException
- in case of an error.org.dom4j.DocumentException
- in case of an error.public void quietDown() throws IOException
IOException
- in case of an error.public void cancelQuietDown() throws IOException
IOException
- in case of an error.public void deleteJob(FolderJob folder, String jobName) throws IOException
folder
- The folder where the given job is located.jobName
- The job which should be deleted.IOException
- in case of an error.public void deleteJob(FolderJob folder, String jobName, boolean crumbFlag) throws IOException
folder
- The folder where the given job is located.jobName
- The job which should be deleted.crumbFlag
- The crumbFlagIOException
- in case of problems.public void deleteJob(String jobName) throws IOException
jobName
- The name of the job which should be deleted.IOException
- in case of an error.public void deleteJob(String jobName, boolean crumbFlag) throws IOException
jobName
- The name of the job to be deleted.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- In case of an failure.public void disableJob(String jobName) throws IOException
jobName
- The name of the job which should be disabled.IOException
- in case of an error.public void disableJob(String jobName, boolean crumbFlag) throws IOException
jobName
- The name of the job to be deleted.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- In case of an failure.public void enableJob(String jobName) throws IOException
jobName
- name of the job which should be enabled.IOException
- In case of an failure.public void enableJob(String jobName, boolean crumbFlag) throws IOException
jobName
- The name of the job to be deleted.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- In case of an failure.public String runScript(String script) throws IOException
script
- The script to be executed.IOException
- in case of an error.public String runScript(String script, boolean crumbFlag) throws IOException
script
- The script to run.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- in case of an error.public Queue getQueue() throws IOException
IOException
public QueueItem getQueueItem(QueueReference ref) throws IOException
IOException
public Build getBuild(QueueItem q) throws IOException
IOException
public void renameJob(String oldJobName, String newJobName) throws IOException
oldJobName
- existing job name.newJobName
- The new job name.IOException
- In case of a failure.public void renameJob(String oldJobName, String newJobName, Boolean crumbFlag) throws IOException
oldJobName
- existing job name.newJobName
- The new job name.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- In case of a failure.public void renameJob(FolderJob folder, String oldJobName, String newJobName) throws IOException
folder
- FolderJob
oldJobName
- existing job name.newJobName
- The new job name.IOException
- In case of a failure.public void renameJob(FolderJob folder, String oldJobName, String newJobName, Boolean crumbFlag) throws IOException
folder
- FolderJob
oldJobName
- existing job name.newJobName
- The new job name.crumbFlag
- true
to add crumbIssuer
false
otherwise.IOException
- In case of a failure.public Map<String,Credential> listCredentials() throws IOException
IOException
public void createCredential(Credential credential, boolean crumbFlag) throws IOException
credential
- a credential instancecrumbFlag
- IOException
public void updateCredential(String credentialId, Credential credential, boolean crumbFlag) throws IOException
credentialId
- the id of the credentialcredential
- the updated credential instancecrumbFlag
- IOException
public void deleteCredential(String credentialId, boolean crumbFlag) throws IOException
credentialId
- the id of the credential to deletecrumbFlag
- IOException
public Plugin findPluginWithName(String pluginShortName) throws IOException
pluginShortName
- the short name of the plugin to findIOException
Copyright © 2017 JBoss by Red Hat. All rights reserved.