Package org.gitlab4j.api
Class JobApi
java.lang.Object
org.gitlab4j.api.AbstractApi
org.gitlab4j.api.JobApi
- All Implemented Interfaces:
Constants
public class JobApi extends AbstractApi implements Constants
This class provides an entry point to all the GitLab API job calls.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gitlab4j.api.Constants
Constants.ActionType, Constants.ApplicationScope, Constants.ArchiveFormat, Constants.AutoDevopsDeployStrategy, Constants.BuildGitStrategy, Constants.CommitBuildState, Constants.ContributorOrderBy, Constants.DeploymentOrderBy, Constants.DeploymentStatus, Constants.DeployTokenScope, Constants.Encoding, Constants.EpicOrderBy, Constants.EventScope, Constants.GroupOrderBy, Constants.GroupSearchScope, Constants.ImpersonationState, Constants.IssueOrderBy, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.MergeRequestOrderBy, Constants.MergeRequestScope, Constants.MergeRequestSearchIn, Constants.MergeRequestState, Constants.MilestoneState, Constants.PackageOrderBy, Constants.PackageStatus, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.ProjectSearchScope, Constants.SearchScope, Constants.SortOrder, Constants.SquashOption, Constants.StateEvent, Constants.TagOrderBy, Constants.TargetType, Constants.TodoAction, Constants.TodoState, Constants.TodoType, Constants.TokenType
-
Field Summary
Fields inherited from class org.gitlab4j.api.AbstractApi
gitLabApi
Fields inherited from interface org.gitlab4j.api.Constants
NEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description Job
cancelJob(Object projectIdOrPath, Long jobId)
Cancel specified job in a project.Job
cancleJob(Object projectIdOrPath, Long jobId)
Deprecated.void
deleteArtifacts(Object projectIdOrPath, Long jobId)
Delete artifacts of a job.InputStream
downloadArtifactsFile(Object projectIdOrPath, Long jobId)
Get an InputStream pointing to the job artifacts file for the specified job ID.File
downloadArtifactsFile(Object projectIdOrPath, Long jobId, File directory)
Download the job artifacts file for the specified job ID.InputStream
downloadArtifactsFile(Object projectIdOrPath, Long jobId, ArtifactsFile artifactsFile)
Download a single artifact file from within the job's artifacts archive.File
downloadArtifactsFile(Object projectIdOrPath, Long jobId, ArtifactsFile artifactsFile, File directory)
Download a single artifact file from within the job's artifacts archive.InputStream
downloadArtifactsFile(Object projectIdOrPath, String ref, String jobName)
Get an InputStream pointing to the artifacts file from the given reference name and job provided the job finished successfully.File
downloadArtifactsFile(Object projectIdOrPath, String ref, String jobName, File directory)
Download the artifacts file from the given reference name and job provided the job finished successfully.InputStream
downloadSingleArtifactsFile(Object projectIdOrPath, Long jobId, Path artifactPath)
Download a single artifact file from within the job's artifacts archive.File
downloadSingleArtifactsFile(Object projectIdOrPath, Long jobId, Path artifactPath, File directory)
Download a single artifact file from within the job's artifacts archive.Job
eraseJob(Object projectIdOrPath, Long jobId)
Erase specified job in a project.Job
getJob(Object projectIdOrPath, Long jobId)
Get single job in a project.List<Job>
getJobs(Object projectIdOrPath)
Get a list of jobs in a project.Pager<Job>
getJobs(Object projectIdOrPath, int itemsPerPage)
Get a Pager of jobs in a project.List<Job>
getJobs(Object projectIdOrPath, int page, int perPage)
Get a list of jobs in a project in the specified page range.List<Job>
getJobs(Object projectIdOrPath, Constants.JobScope scope)
Get a list of jobs in a project.Pager<Job>
getJobs(Object projectIdOrPath, Constants.JobScope scope, int itemsPerPage)
Get a list of jobs in a project.List<Job>
getJobsForPipeline(Object projectIdOrPath, long pipelineId)
Get a list of jobs in a pipeline.Pager<Job>
getJobsForPipeline(Object projectIdOrPath, long pipelineId, int itemsPerPage)
Get a Pager of jobs in a pipeline.List<Job>
getJobsForPipeline(Object projectIdOrPath, long pipelineId, Constants.JobScope scope)
Get a list of jobs in a pipeline.Stream<Job>
getJobsStream(Object projectIdOrPath)
Get a Stream of jobs in a project.Stream<Job>
getJobsStream(Object projectIdOrPath, long pipelineId)
Get a Stream of jobs in a pipeline.Stream<Job>
getJobsStream(Object projectIdOrPath, Constants.JobScope scope)
Get a Stream of jobs in a project.Optional<Job>
getOptionalJob(Object projectIdOrPath, Long jobId)
Get single job in a project as an Optional instance.String
getTrace(Object projectIdOrPath, Long jobId)
Get a trace of a specific job of a projectJob
keepArtifacts(Object projectIdOrPath, Long jobId)
Prevents artifacts from being deleted when expiration is set.Job
playJob(Object projectIdOrPath, Long jobId)
Play specified job in a project.Job
retryJob(Object projectIdOrPath, Long jobId)
Retry specified job in a project.Methods inherited from class org.gitlab4j.api.AbstractApi
addFormParam, addFormParam, delete, delete, get, get, getApiClient, getApiVersion, getDefaultPerPage, getDefaultPerPageParam, getDefaultPerPageParam, getGroupIdOrPath, getLabelIdOrName, getPageQueryParams, getPageQueryParams, getPerPageQueryParam, getProjectIdOrPath, getUserIdOrUsername, getWithAccepts, handle, head, isApiVersion, post, post, post, post, post, put, put, put, putUpload, putUpload, putWithFormData, upload, upload, upload, upload, urlEncode, validate
-
Constructor Details
-
JobApi
-
-
Method Details
-
getJobs
Get a list of jobs in a project.GitLab Endpoint: GET /projects/:id/jobs
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path- Returns:
- a list containing the jobs for the specified project ID
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getJobs
Get a list of jobs in a project in the specified page range.GitLab Endpoint: GET /projects/:id/jobs
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path to get the jobs forpage
- the page to getperPage
- the number of Job instances per page- Returns:
- a list containing the jobs for the specified project ID in the specified page range
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getJobs
Get a Pager of jobs in a project.GitLab Endpoint: GET /projects/:id/jobs
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path to get the jobs foritemsPerPage
- the number of Job instances that will be fetched per page- Returns:
- a Pager containing the jobs for the specified project ID
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getJobsStream
Get a Stream of jobs in a project.GitLab Endpoint: GET /projects/:id/jobs
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path- Returns:
- a Stream containing the jobs for the specified project ID
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getJobs
public List<Job> getJobs(Object projectIdOrPath, Constants.JobScope scope) throws GitLabApiExceptionGet a list of jobs in a project.GitLab Endpoint: GET /projects/:id/jobs
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path to get the jobs forscope
- the scope of jobs, one of: CREATED, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL- Returns:
- a list containing the jobs for the specified project ID
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getJobs
public Pager<Job> getJobs(Object projectIdOrPath, Constants.JobScope scope, int itemsPerPage) throws GitLabApiExceptionGet a list of jobs in a project.GitLab Endpoint: GET /projects/:id/jobs
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path to get the jobs forscope
- the scope of jobs, one of: CREATED, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUALitemsPerPage
- the number of Job instances that will be fetched per page- Returns:
- a list containing the jobs for the specified project ID
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getJobsStream
public Stream<Job> getJobsStream(Object projectIdOrPath, Constants.JobScope scope) throws GitLabApiExceptionGet a Stream of jobs in a project.GitLab Endpoint: GET /projects/:id/jobs
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path to get the jobs forscope
- the scope of jobs, one of: CREATED, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL- Returns:
- a Stream containing the jobs for the specified project ID
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getJobsForPipeline
public List<Job> getJobsForPipeline(Object projectIdOrPath, long pipelineId) throws GitLabApiExceptionGet a list of jobs in a pipeline.GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path to get the pipelines forpipelineId
- the pipeline ID to get the list of jobs for- Returns:
- a list containing the jobs for the specified project ID and pipeline ID
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getJobsForPipeline
public List<Job> getJobsForPipeline(Object projectIdOrPath, long pipelineId, Constants.JobScope scope) throws GitLabApiExceptionGet a list of jobs in a pipeline.GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path to get the pipelines forpipelineId
- the pipeline ID to get the list of jobs forscope
- the scope of jobs, one of: CREATED, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL- Returns:
- a list containing the jobs for the specified project ID and pipeline ID
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getJobsForPipeline
public Pager<Job> getJobsForPipeline(Object projectIdOrPath, long pipelineId, int itemsPerPage) throws GitLabApiExceptionGet a Pager of jobs in a pipeline.GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path to get the pipelines forpipelineId
- the pipeline ID to get the list of jobs foritemsPerPage
- the number of Job instances that will be fetched per page- Returns:
- a list containing the jobs for the specified project ID and pipeline ID
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getJobsStream
public Stream<Job> getJobsStream(Object projectIdOrPath, long pipelineId) throws GitLabApiExceptionGet a Stream of jobs in a pipeline.GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/jobs
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathpipelineId
- the pipeline ID to get the list of jobs for- Returns:
- a Stream containing the jobs for the specified project ID
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getJob
Get single job in a project.GitLab Endpoint: GET /projects/:id/jobs/:job_id
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path to get the job forjobId
- the job ID to get- Returns:
- a single job for the specified project ID
- Throws:
GitLabApiException
- if any exception occurs during execution
-
getOptionalJob
Get single job in a project as an Optional instance.GitLab Endpoint: GET /projects/:id/jobs/:job_id
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path to get the job forjobId
- the job ID to get- Returns:
- a single job for the specified project ID as an Optional intance
-
downloadArtifactsFile
public File downloadArtifactsFile(Object projectIdOrPath, String ref, String jobName, File directory) throws GitLabApiExceptionDownload the artifacts file from the given reference name and job provided the job finished successfully. The file will be saved to the specified directory. If the file already exists in the directory it will be overwritten.GitLab Endpoint: GET /projects/:id/jobs/artifacts/:ref_name/download?job=name
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathref
- the ref from a repositoryjobName
- the name of the job to download the artifacts fordirectory
- the File instance of the directory to save the file to, if null will use "java.io.tmpdir"- Returns:
- a File instance pointing to the download of the specified artifacts file
- Throws:
GitLabApiException
- if any exception occurs
-
downloadArtifactsFile
public InputStream downloadArtifactsFile(Object projectIdOrPath, String ref, String jobName) throws GitLabApiExceptionGet an InputStream pointing to the artifacts file from the given reference name and job provided the job finished successfully. The file will be saved to the specified directory. If the file already exists in the directory it will be overwritten.GitLab Endpoint: GET /projects/:id/jobs/artifacts/:ref_name/download?job=name
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathref
- the ref from a repositoryjobName
- the name of the job to download the artifacts for- Returns:
- an InputStream to read the specified artifacts file from
- Throws:
GitLabApiException
- if any exception occurs
-
downloadArtifactsFile
public File downloadArtifactsFile(Object projectIdOrPath, Long jobId, File directory) throws GitLabApiExceptionDownload the job artifacts file for the specified job ID. The artifacts file will be saved in the specified directory with the following name pattern: job-{jobid}-artifacts.zip. If the file already exists in the directory it will be overwritten.GitLab Endpoint: GET /projects/:id/jobs/:job_id/artifacts
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the job ID to get the artifacts fordirectory
- the File instance of the directory to save the file to, if null will use "java.io.tmpdir"- Returns:
- a File instance pointing to the download of the specified job artifacts file
- Throws:
GitLabApiException
- if any exception occurs
-
downloadArtifactsFile
public InputStream downloadArtifactsFile(Object projectIdOrPath, Long jobId) throws GitLabApiExceptionGet an InputStream pointing to the job artifacts file for the specified job ID.GitLab Endpoint: GET /projects/:id/jobs/:job_id/artifacts
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the job ID to get the artifacts for- Returns:
- an InputStream to read the specified job artifacts file
- Throws:
GitLabApiException
- if any exception occurs
-
downloadArtifactsFile
public File downloadArtifactsFile(Object projectIdOrPath, Long jobId, ArtifactsFile artifactsFile, File directory) throws GitLabApiExceptionDownload a single artifact file from within the job's artifacts archive. Only a single file is going to be extracted from the archive and streamed to a client.GitLab Endpoint: GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the unique job identifierartifactsFile
- an ArtifactsFile instance for the artifact to downloaddirectory
- the File instance of the directory to save the file to, if null will use "java.io.tmpdir"- Returns:
- a File instance pointing to the download of the specified artifacts file
- Throws:
GitLabApiException
- if any exception occurs
-
downloadArtifactsFile
public InputStream downloadArtifactsFile(Object projectIdOrPath, Long jobId, ArtifactsFile artifactsFile) throws GitLabApiExceptionDownload a single artifact file from within the job's artifacts archive. Only a single file is going to be extracted from the archive and streamed to a client.GitLab Endpoint: GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the unique job identifierartifactsFile
- an ArtifactsFile instance for the artifact to download- Returns:
- an InputStream to read the specified artifacts file from
- Throws:
GitLabApiException
- if any exception occurs
-
downloadSingleArtifactsFile
public File downloadSingleArtifactsFile(Object projectIdOrPath, Long jobId, Path artifactPath, File directory) throws GitLabApiExceptionDownload a single artifact file from within the job's artifacts archive. Only a single file is going to be extracted from the archive and streamed to a client.GitLab Endpoint: GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the unique job identifierartifactPath
- the Path to a file inside the artifacts archivedirectory
- the File instance of the directory to save the file to, if null will use "java.io.tmpdir"- Returns:
- a File instance pointing to the download of the specified artifacts file
- Throws:
GitLabApiException
- if any exception occurs
-
downloadSingleArtifactsFile
public InputStream downloadSingleArtifactsFile(Object projectIdOrPath, Long jobId, Path artifactPath) throws GitLabApiExceptionDownload a single artifact file from within the job's artifacts archive. Only a single file is going to be extracted from the archive and streamed to a client.GitLab Endpoint: GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the unique job identifierartifactPath
- the Path to a file inside the artifacts archive- Returns:
- an InputStream to read the specified artifacts file from
- Throws:
GitLabApiException
- if any exception occurs
-
getTrace
Get a trace of a specific job of a projectGitLab Endpoint: GET /projects/:id/jobs/:id/trace
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or path to get the specified job's trace forjobId
- the job ID to get the trace for- Returns:
- a String containing the specified job's trace
- Throws:
GitLabApiException
- if any exception occurs during execution
-
cancleJob
Deprecated.replaced bycancelJob(Object, Long)
Cancel specified job in a project.GitLab Endpoint: POST /projects/:id/jobs/:job_id/cancel
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the ID to cancel job- Returns:
- job instance which just canceled
- Throws:
GitLabApiException
- if any exception occurs during execution
-
cancelJob
Cancel specified job in a project.GitLab Endpoint: POST /projects/:id/jobs/:job_id/cancel
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the ID to cancel job- Returns:
- job instance which just canceled
- Throws:
GitLabApiException
- if any exception occurs during execution
-
retryJob
Retry specified job in a project.GitLab Endpoint: POST /projects/:id/jobs/:job_id/retry
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the ID to retry job- Returns:
- job instance which just retried
- Throws:
GitLabApiException
- if any exception occurs during execution
-
eraseJob
Erase specified job in a project.GitLab Endpoint: POST /projects/:id/jobs/:job_id/erase
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the ID to erase job- Returns:
- job instance which just erased
- Throws:
GitLabApiException
- if any exception occurs during execution
-
playJob
Play specified job in a project.GitLab Endpoint: POST /projects/:id/jobs/:job_id/play
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the ID to play job- Returns:
- job instance which just played
- Throws:
GitLabApiException
- if any exception occurs during execution
-
keepArtifacts
Prevents artifacts from being deleted when expiration is set.GitLab Endpoint: POST /projects/:id/jobs/:job_id/keep
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the ID to keep artifacts for- Returns:
- the Job instance that was just modified
- Throws:
GitLabApiException
- if any exception occurs during execution
-
deleteArtifacts
Delete artifacts of a job.GitLab Endpoint: DELETE /projects/:id/jobs/:job_id/artifacts
- Parameters:
projectIdOrPath
- id, path of the project, or a Project instance holding the project ID or pathjobId
- the ID to delete artifacts for- Throws:
GitLabApiException
- if any exception occurs during execution
-
cancelJob(Object, Long)