001/* 002 * SonarQube 003 * Copyright (C) 2009-2018 SonarSource SA 004 * mailto:info AT sonarsource DOT com 005 * 006 * This program is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public License 017 * along with this program; if not, write to the Free Software Foundation, 018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 */ 020package org.sonar.api.ce.posttask; 021 022import java.util.Date; 023import java.util.Optional; 024import javax.annotation.CheckForNull; 025import org.sonar.api.ExtensionPoint; 026import org.sonar.api.ce.ComputeEngineSide; 027 028/** 029 * Extension point of which any plugin can provide an implementation and will allow them to be notified whenever some 030 * analysis report processing ends in the Compute Engine. 031 * 032 * <p> 033 * If more then one implementation of {@link PostProjectAnalysisTask} is found, they will be executed in no specific order. 034 * 035 * 036 * <p> 037 * Class {@link PostProjectAnalysisTaskTester} is provided to write unit tests of implementations of this interface. 038 * 039 * 040 * @since 5.5 041 * @see PostProjectAnalysisTaskTester 042 */ 043@ExtensionPoint 044@ComputeEngineSide 045public interface PostProjectAnalysisTask { 046 /** 047 * This method is called whenever the processing of a Project analysis has finished, whether successfully or not. 048 */ 049 void finished(ProjectAnalysis analysis); 050 051 /** 052 * @since 5.5 053 */ 054 interface ProjectAnalysis { 055 /** 056 * When organizations are enabled in SonarQube, the organization the project belongs to. 057 * 058 * @since 7.0 059 * @return a non empty value when organizations are enabled, otherwise empty 060 */ 061 Optional<Organization> getOrganization(); 062 063 /** 064 * Details of the Compute Engine task in which the project analysis was run. 065 */ 066 CeTask getCeTask(); 067 068 /** 069 * Details of the analyzed project. 070 */ 071 Project getProject(); 072 073 /** 074 * The branch that is being analyzed. 075 * 076 * @since 6.6 077 */ 078 Optional<Branch> getBranch(); 079 080 /** 081 * Status and details of the Quality Gate of the project (if any was configured on the project). 082 */ 083 @CheckForNull 084 QualityGate getQualityGate(); 085 086 /** 087 * Date of the analysis. 088 * <p> 089 * This date is the same as the date of the project analysis report and the snapshot. 090 * 091 * @deprecated use {@link #getAnalysis().getDate()} instead. When {@link #getAnalysis()} returns 092 * {@link Optional#empty() empty}, the current date will be returned. 093 */ 094 @Deprecated 095 Date getDate(); 096 097 /** 098 * Date of the analysis. 099 * <p> 100 * This date is the same as the date of the project analysis report and therefore as the analysis in DB. It can be 101 * missing when the status of the task is {@link org.sonar.api.ce.posttask.CeTask.Status#FAILED FAILED}. 102 * </p> 103 * @deprecated use {@link #getAnalysis().getDate()} instead 104 */ 105 @Deprecated 106 Optional<Date> getAnalysisDate(); 107 108 /** 109 * Analysis containing the UUID of the analysis and the date 110 * 111 * <p> 112 * This Analysis can be missing when the status of the task is 113 * {@link org.sonar.api.ce.posttask.CeTask.Status#FAILED FAILED}. 114 * </p> 115 */ 116 Optional<Analysis> getAnalysis(); 117 118 /** 119 * Context as defined by scanner through {@link org.sonar.api.batch.sensor.SensorContext#addContextProperty(String, String)}. 120 * It does not contain the settings used by scanner. 121 * 122 * @since 6.1 123 */ 124 ScannerContext getScannerContext(); 125 } 126}