-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathAbstractSCMBridge.java
100 lines (85 loc) · 3.16 KB
/
AbstractSCMBridge.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package org.jenkinsci.plugins.pretestedintegration;
import hudson.DescriptorExtensionList;
import hudson.EnvVars;
import hudson.ExtensionPoint;
import hudson.model.AbstractProject;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Result;
import jenkins.model.Jenkins;
import org.jenkinsci.plugins.pretestedintegration.exceptions.UnsupportedConfigurationException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
/**
* Abstract class representing an SCM bridge.
*/
public abstract class AbstractSCMBridge implements Describable<AbstractSCMBridge>, ExtensionPoint {
private static final Logger LOGGER = Logger.getLogger(AbstractSCMBridge.class.getName());
/**
* Information about the result of the integration (Unknown, Conflict, Build, Push).
* @return the integration branch name
*/
protected abstract String getIntegrationBranch();
/**
* The integration strategy.
* This is the strategy applied to merge pretested commits into the integration integrationBranch.
*/
public final IntegrationStrategy integrationStrategy;
protected final static String LOG_PREFIX = "[PREINT] ";
/**
* Constructor for the SCM bridge.
*
* @param integrationStrategy The integration strategy to apply when merging commits.
*/
public AbstractSCMBridge(IntegrationStrategy integrationStrategy ) {
this.integrationStrategy = integrationStrategy;
}
/**
* Validates the configuration of the Jenkins Job.
* Throws an exception when the configuration is invalid.
*
* @param project The Project
* @throws UnsupportedConfigurationException Mismatch in job configuration
*/
public void validateConfiguration(AbstractProject<?, ?> project) throws UnsupportedConfigurationException {
}
/**
* @return all the SCM Bridge Descriptors
*/
public static DescriptorExtensionList<AbstractSCMBridge, SCMBridgeDescriptor<AbstractSCMBridge>> all() {
return Jenkins.getInstance().<AbstractSCMBridge, SCMBridgeDescriptor<AbstractSCMBridge>>getDescriptorList(AbstractSCMBridge.class);
}
/**
* @return all the Integration Strategy Descriptors
*/
public static List<IntegrationStrategyDescriptor<?>> getBehaviours() {
return new ArrayList<>(IntegrationStrategy.all());
}
/**
* {@inheritDoc}
*/
@Override
public Descriptor<AbstractSCMBridge> getDescriptor() {
return (SCMBridgeDescriptor<?>) Jenkins.getInstance().getDescriptorOrDie(getClass());
}
/**
* @return all the SCM Bridge Descriptors
*/
public static List<SCMBridgeDescriptor<?>> getDescriptors() {
return new ArrayList<>(all());
}
/**
* @param environment environment
* @return The Integration Branch name as variable expanded if possible - otherwise return integrationBranch
*/
public String getExpandedIntegrationBranch(EnvVars environment) {
return environment.expand(getIntegrationBranch());
}
/***
* @return The required result
*/
public static Result getRequiredResult() {
return Result.SUCCESS;
}
}