Interface JobService

  • All Known Implementing Classes:
    JobServiceImpl

    public interface JobService
    Service for performing job related configurations
    Since:
    v5.7
    • Method Detail

      • getJobsForPlan

        @NotNull
        @NotNull List<ImmutableJob> getJobsForPlan​(@NotNull
                                                   @NotNull PlanKey planKey)
        Get all jobs in a plan, ordered alphabetically
        Parameters:
        planKey - of plan
        Returns:
        list of immutable jobs
        Throws:
        NotFoundException - if the plan does not exist
      • getJobsForStage

        @NotNull
        @NotNull List<ImmutableJob> getJobsForStage​(@NotNull
                                                    @NotNull PlanKey planKey,
                                                    long stageId)
        Get all jobs in a particular stage, ordered alphabetically
        Parameters:
        planKey - of plan
        stageId - id of the stage
        Returns:
        list of immutable jobs
        Throws:
        NotFoundException - if plan or stage does not exist
      • validateJobForAdd

        @NotNull
        @NotNull ErrorCollection validateJobForAdd​(@NotNull
                                                   @NotNull PlanKey chainKey,
                                                   long stageId,
                                                   @Nullable
                                                   @Nullable String jobKey,
                                                   @Nullable
                                                   @Nullable String name,
                                                   @Nullable
                                                   @Nullable String description,
                                                   boolean suspended)
                                            throws WebValidationException
        Validates the parameters for adding a job.
        Parameters:
        chainKey - of the plan to add job to.
        stageId - of the stage to add the job to.
        jobKey - key of the job to add. May be full or partial job key.
        name - name of the job to add.
        description - description of the job.
        suspended - sets the job's suspended status.
        Returns:
        error collection containing any validation errors that may have occurred against job data.
        Throws:
        NotFoundException - if the plan or stage can't be found
        WebValidationException
      • getJob

        @NotNull
        @NotNull ImmutableJob getJob​(@NotNull
                                     @NotNull PlanKey jobKey)
        Get an individual job. In clustered mode, there is NO consistency guarantee.
        Parameters:
        jobKey - of the job to get
        Returns:
        the job
        Throws:
        NotFoundException - if the job doesn't exist
        org.acegisecurity.AccessDeniedException - if user has no WRITE access to the job
      • getJobWithConsistencyGuarantee

        @NotNull
        @NotNull ImmutableJob getJobWithConsistencyGuarantee​(@NotNull
                                                             @NotNull PlanKey jobKey)
        Get an individual job. There is a guarantee that the data will be up-to-date.
        Parameters:
        jobKey - of the job to get
        Returns:
        the job
        Throws:
        NotFoundException - if the job doesn't exist
        org.acegisecurity.AccessDeniedException - if user has no WRITE access to the job
        Since:
        9.4
      • addJob

        @NotNull
        @NotNull ImmutableJob addJob​(@NotNull
                                     @NotNull PlanKey chainKey,
                                     long stageId,
                                     @NotNull
                                     @NotNull String jobKey,
                                     @NotNull
                                     @NotNull String name,
                                     @Nullable
                                     @Nullable String description,
                                     boolean suspended)
                              throws WebValidationException
        Add a job to an existing stage in the plan
        Parameters:
        chainKey - of the plan to add the job
        stageId - of the stage to add the job
        jobKey - of the job to add. May be full or partial job key.
        name - name of the job
        description - description of the job
        suspended - sets the job suspended status
        Returns:
        added job
        Throws:
        NotFoundException - if the plan or stage can't be found
        WebValidationException
      • validateJobForClone

        @NotNull
        @NotNull ErrorCollection validateJobForClone​(@Nullable
                                                     @Nullable String sourceJobKey,
                                                     @NotNull
                                                     @NotNull PlanKey chainKey,
                                                     long stageId,
                                                     @Nullable
                                                     @Nullable String newJobKey,
                                                     @Nullable
                                                     @Nullable String name,
                                                     @Nullable
                                                     @Nullable String description,
                                                     @Nullable
                                                     @Nullable Boolean suspended)
                                              throws WebValidationException
        Validates the parameters for cloning a job.
        Parameters:
        sourceJobKey - key of the job to clone. Must be full job key.
        chainKey - key of the plan to add the new job to.
        stageId - id of the stage to add the new job to.
        newJobKey - key of the new job. May be full or partial job key.
        name - name of the new job.
        description - description of the new job.
        suspended - suspended state of the new job.
        Returns:
        error collection containing any validation errors that may have occurred against job data.
        Throws:
        WebValidationException
      • cloneJob

        @NotNull
        @NotNull ImmutableJob cloneJob​(@NotNull
                                       @NotNull String sourceJobKey,
                                       @NotNull
                                       @NotNull PlanKey chainKey,
                                       long stageId,
                                       @NotNull
                                       @NotNull String newJobKey,
                                       @NotNull
                                       @NotNull String name,
                                       @Nullable
                                       @Nullable String description,
                                       boolean suspended)
                                throws WebValidationException
        Copy the given job and give the copy the key, name, description and suspended state provided.
        Parameters:
        sourceJobKey - key of the source job to copy. Must be full job key.
        chainKey - of the plan to add the new job.
        stageId - of the stage to add the new job.
        newJobKey - key to give to the new job. May be full or partial job key.
        name - The name of the cloned job.
        description - The description of the cloned job.
        suspended - The suspended state of the cloned job.
        Returns:
        the result of the copy.
        Throws:
        WebValidationException
      • validateJobForUpdate

        @NotNull
        @NotNull ErrorCollection validateJobForUpdate​(@NotNull
                                                      @NotNull PlanKey jobKey,
                                                      @NotNull
                                                      @NotNull String name,
                                                      @Nullable
                                                      @Nullable String description,
                                                      boolean suspended,
                                                      long stageId)
        Validate editing of a job
        Parameters:
        jobKey - of the job to update
        name - new name of the job
        description - new description of the job
        suspended - sets the job suspended status
        Returns:
        error collection containing any validation errors that may have occurred against job data.
        Throws:
        NotFoundException - if the job doesn't exist
      • updateJob

        @NotNull
        @NotNull ImmutableJob updateJob​(@NotNull
                                        @NotNull PlanKey jobKey,
                                        @NotNull
                                        @NotNull String name,
                                        @Nullable
                                        @Nullable String description,
                                        boolean suspended,
                                        long stageId,
                                        @NotNull
                                        @NotNull BambooClosures.Throwing1<ImmutableJob,​WebValidationException>... runBefore)
                                 throws WebValidationException
        Update the details of a job
        Parameters:
        jobKey - of the job to update
        name - new name of the job
        description - new description of the job
        suspended - sets the job suspended status
        stageId - new stage for the job
        runBefore - code to execute after security and validation has passed but before the update occurs.
        Returns:
        updated job
        Throws:
        WebValidationException