Class JenkinsService
java.lang.Object
fr.paris.lutece.plugins.releaser.service.JenkinsService
- All Implemented Interfaces:
IJenkinsService
-
Nested Class Summary
Nested classes/interfaces inherited from interface fr.paris.lutece.plugins.releaser.service.IJenkinsService
IJenkinsService.QueueItemCancelledException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBuildResult(String strBuildUrl) Returns the result of a build.getQueuedBuild(String strQueueUrl) Reads a queue item once.static IJenkinsServiceGets the service.voidinit()Loads the Jenkins configuration.readArtifact(String strBuildUrl, String strArtifactPath) Reads an artifact archived by a build.triggerJob(String strJobPath, Map<String, String> mapParams) Triggers a parameterized job.TriggerPipeline(WorkflowReleaseContext context) Triggers the configured docker image pipeline for a site and waits for its result, logging in the release console.waitForBuild(String strQueueUrl) Waits until a queued item becomes a build.
-
Constructor Details
-
JenkinsService
public JenkinsService()
-
-
Method Details
-
getService
Gets the service.- Returns:
- the service
-
init
public void init()Description copied from interface:IJenkinsServiceLoads the Jenkins configuration.- Specified by:
initin interfaceIJenkinsService
-
TriggerPipeline
Description copied from interface:IJenkinsServiceTriggers the configured docker image pipeline for a site and waits for its result, logging in the release console.- Specified by:
TriggerPipelinein interfaceIJenkinsService- Parameters:
context- the release context- Returns:
- the build result (SUCCESS, FAILURE...), null on error
-
triggerJob
public String triggerJob(String strJobPath, Map<String, String> mapParams) throws fr.paris.lutece.util.httpaccess.HttpAccessExceptionDescription copied from interface:IJenkinsServiceTriggers a parameterized job.- Specified by:
triggerJobin interfaceIJenkinsService- Parameters:
strJobPath- the job path relative to the Jenkins base URL (ex :job/lutece-release-platform-step)mapParams- the build parameters- Returns:
- the URL of the queue item
- Throws:
fr.paris.lutece.util.httpaccess.HttpAccessException- if Jenkins cannot be reached or refuses the request
-
waitForBuild
public JenkinsBuild waitForBuild(String strQueueUrl) throws fr.paris.lutece.util.httpaccess.HttpAccessException, IOException, InterruptedException Description copied from interface:IJenkinsServiceWaits until a queued item becomes a build.- Specified by:
waitForBuildin interfaceIJenkinsService- Parameters:
strQueueUrl- the URL of the queue item- Returns:
- the build
- Throws:
fr.paris.lutece.util.httpaccess.HttpAccessException- if Jenkins cannot be reachedIOException- if the Jenkins answer cannot be readInterruptedException- if the wait is interrupted
-
getQueuedBuild
public JenkinsBuild getQueuedBuild(String strQueueUrl) throws fr.paris.lutece.util.httpaccess.HttpAccessException, IOException Description copied from interface:IJenkinsServiceReads a queue item once.- Specified by:
getQueuedBuildin interfaceIJenkinsService- Parameters:
strQueueUrl- the URL of the queue item- Returns:
- the build once Jenkins has started it, null while the item is still queued
- Throws:
fr.paris.lutece.util.httpaccess.HttpAccessException- if Jenkins cannot be reachedIJenkinsService.QueueItemCancelledException- if the item was cancelled before it started : no build will ever runIOException- if the Jenkins answer cannot be read
-
getBuildResult
public String getBuildResult(String strBuildUrl) throws fr.paris.lutece.util.httpaccess.HttpAccessException, IOException Description copied from interface:IJenkinsServiceReturns the result of a build.- Specified by:
getBuildResultin interfaceIJenkinsService- Parameters:
strBuildUrl- the build URL- Returns:
- the result (SUCCESS, FAILURE, UNSTABLE, ABORTED), null while the build is running
- Throws:
fr.paris.lutece.util.httpaccess.HttpAccessException- if Jenkins cannot be reachedIOException- if the Jenkins answer cannot be read
-
readArtifact
public String readArtifact(String strBuildUrl, String strArtifactPath) throws fr.paris.lutece.util.httpaccess.HttpAccessException Description copied from interface:IJenkinsServiceReads an artifact archived by a build.- Specified by:
readArtifactin interfaceIJenkinsService- Parameters:
strBuildUrl- the build URLstrArtifactPath- the artifact path relative to the workspace (ex :step-report.json)- Returns:
- the artifact content
- Throws:
fr.paris.lutece.util.httpaccess.HttpAccessException- if Jenkins cannot be reached or the artifact does not exist
-