Package io.fabric8.jenkins.openshiftsync
Class OpenShiftUtils
java.lang.Object
io.fabric8.jenkins.openshiftsync.OpenShiftUtils
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidaddAnnotation(io.fabric8.kubernetes.api.model.HasMetadata resource, String name, String value) static NamespaceNamebuildConfigNameFromJenkinsJobName(String jobName, String namespace) Maps a Jenkins Job name to an ObjectShift BuildConfig namestatic StringdumpWithoutRuntimeStateAsYaml(io.fabric8.kubernetes.api.model.HasMetadata obj) static StringformatTimestamp(long timestamp) static StringgetAnnotation(io.fabric8.kubernetes.api.model.HasMetadata resource, String name) static io.fabric8.openshift.client.OpenShiftClientstatic StringgetExternalServiceUrl(io.fabric8.openshift.client.OpenShiftClient openShiftClient, String defaultProtocolText, String namespace, String serviceName) Returns the public URL of the given servicestatic ItemGroupgetFullNameParent(Jenkins activeJenkins, String fullName, String namespace) Returns the parent for the given item full name or default to the active jenkins if it does not existstatic io.fabric8.kubernetes.client.informers.SharedInformerFactorystatic StringgetJenkinsURL(io.fabric8.openshift.client.OpenShiftClient openShiftClient, String namespace) Calculates the external URL to access Jenkinsstatic Stringstatic StringgetName(io.fabric8.kubernetes.api.model.HasMetadata resource) static StringgetNamespace(io.fabric8.kubernetes.api.model.HasMetadata resource) static Stringstatic String[]getNamespaceOrUseDefault(String[] configuredNamespaces, io.fabric8.openshift.client.OpenShiftClient client) Gets the current namespace running Jenkins inside or returns a reasonable defaultprotected static io.fabric8.openshift.client.OpenShiftClientstatic io.fabric8.openshift.client.OpenShiftClientstatic voidinitializeOpenShiftClient(String serverUrl, int maxConnections) Initializes anOpenShiftClientstatic booleanisCancellable(io.fabric8.openshift.api.model.BuildStatus buildStatus) static booleanisCancelled(io.fabric8.openshift.api.model.BuildStatus status) static booleanisNew(io.fabric8.openshift.api.model.BuildStatus buildStatus) static booleanisPipelineStrategyBuild(io.fabric8.openshift.api.model.Build b) static booleanisPipelineStrategyBuildConfig(io.fabric8.openshift.api.model.BuildConfig bc) Checks if aBuildConfigrelates to a Jenkins buildstatic booleanisResourceWithoutStateEqual(io.fabric8.kubernetes.api.model.HasMetadata oldObj, io.fabric8.kubernetes.api.model.HasMetadata newObj) static StringjenkinsJobDisplayName(io.fabric8.openshift.api.model.BuildConfig bc) Finds the Jenkins job display name for the givenBuildConfig.static StringjenkinsJobDisplayName(String namespace, String buildConfigName) Creates the Jenkins Job display name for the given buildConfigNamestatic StringjenkinsJobFullName(io.fabric8.openshift.api.model.BuildConfig bc) Finds the full jenkins job path including folders for the givenBuildConfig.static StringjenkinsJobName(io.fabric8.openshift.api.model.BuildConfig bc) Finds the Jenkins job name for the givenBuildConfig.static StringjenkinsJobName(String namespace, String buildConfigName) Creates the Jenkins Job name for the given buildConfigNamestatic longparseResourceVersion(io.fabric8.kubernetes.api.model.HasMetadata obj) static longparseResourceVersion(String resourceVersion) static longparseTimestamp(String timestamp) static voidstatic voidupdateGitSourceUrl(io.fabric8.openshift.api.model.BuildConfig buildConfig, String gitUrl, String ref) Lazily creates the GitSource if need be then updates the git URLstatic voidupdateOpenShiftBuildPhase(io.fabric8.openshift.api.model.Build build, String phase) 
- 
Constructor Details- 
OpenShiftUtilspublic OpenShiftUtils()
 
- 
- 
Method Details- 
initializeOpenShiftClientInitializes anOpenShiftClient- Parameters:
- serverUrl- the optional URL of where the OpenShift cluster API server is running
- maxConnections- the maximum number of connections
 
- 
getOpenShiftClientpublic static io.fabric8.openshift.client.OpenShiftClient getOpenShiftClient()
- 
getAuthenticatedOpenShiftClientpublic static io.fabric8.openshift.client.OpenShiftClient getAuthenticatedOpenShiftClient()
- 
getInformerFactorypublic static io.fabric8.kubernetes.client.informers.SharedInformerFactory getInformerFactory()
- 
shutdownOpenShiftClientpublic static void shutdownOpenShiftClient()
- 
isPipelineStrategyBuildConfigpublic static boolean isPipelineStrategyBuildConfig(io.fabric8.openshift.api.model.BuildConfig bc) Checks if aBuildConfigrelates to a Jenkins build- Parameters:
- bc- the BuildConfig
- Returns:
- true if this is an OpenShift BuildConfig which should be mirrored to a Jenkins Job
 
- 
isPipelineStrategyBuildpublic static boolean isPipelineStrategyBuild(io.fabric8.openshift.api.model.Build b) 
- 
jenkinsJobNameFinds the Jenkins job name for the givenBuildConfig.- Parameters:
- bc- the BuildConfig
- Returns:
- the jenkins job name for the given BuildConfig
 
- 
jenkinsJobNameCreates the Jenkins Job name for the given buildConfigName- Parameters:
- namespace- the namespace of the build
- buildConfigName- the name of the- BuildConfigin in the namespace
- Returns:
- the jenkins job name for the given namespace and name
 
- 
jenkinsJobFullNameFinds the full jenkins job path including folders for the givenBuildConfig.- Parameters:
- bc- the BuildConfig
- Returns:
- the jenkins job name for the given BuildConfig
 
- 
getFullNameParentReturns the parent for the given item full name or default to the active jenkins if it does not exist- Parameters:
- activeJenkins- the active Jenkins instance
- fullName- the full name of the instance
- namespace- the namespace where the instance runs
- Returns:
- and ItemGroup representing the full parent
 
- 
jenkinsJobDisplayNameFinds the Jenkins job display name for the givenBuildConfig.- Parameters:
- bc- the BuildConfig
- Returns:
- the jenkins job display name for the given BuildConfig
 
- 
jenkinsJobDisplayNameCreates the Jenkins Job display name for the given buildConfigName- Parameters:
- namespace- the namespace of the build
- buildConfigName- the name of the- BuildConfigin in the namespace
- Returns:
- the jenkins job display name for the given namespace and name
 
- 
getNamespaceOrUseDefaultpublic static String[] getNamespaceOrUseDefault(String[] configuredNamespaces, io.fabric8.openshift.client.OpenShiftClient client) Gets the current namespace running Jenkins inside or returns a reasonable default- Parameters:
- configuredNamespaces- the optional configured namespace(s)
- client- the OpenShift client
- Returns:
- the default namespace using either the configuration value, the default namespace on the client or "default"
 
- 
getExternalServiceUrlpublic static String getExternalServiceUrl(io.fabric8.openshift.client.OpenShiftClient openShiftClient, String defaultProtocolText, String namespace, String serviceName) Returns the public URL of the given service- Parameters:
- openShiftClient- the OpenShiftClient to use
- defaultProtocolText- the protocol text part of a URL such as- http://
- namespace- the Kubernetes namespace
- serviceName- the service name
- Returns:
- the external URL of the service
 
- 
getJenkinsURLpublic static String getJenkinsURL(io.fabric8.openshift.client.OpenShiftClient openShiftClient, String namespace) Calculates the external URL to access Jenkins- Parameters:
- namespace- the namespace Jenkins is runing inside
- openShiftClient- the OpenShift client
- Returns:
- the external URL to access Jenkins
 
- 
getNamespacefromPodInputs
- 
updateGitSourceUrlpublic static void updateGitSourceUrl(io.fabric8.openshift.api.model.BuildConfig buildConfig, String gitUrl, String ref) Lazily creates the GitSource if need be then updates the git URL- Parameters:
- buildConfig- the BuildConfig to update
- gitUrl- the URL to the git repo
- ref- the git ref (commit/branch/etc) for the build
 
- 
updateOpenShiftBuildPhasepublic static void updateOpenShiftBuildPhase(io.fabric8.openshift.api.model.Build build, String phase) 
- 
buildConfigNameFromJenkinsJobNameMaps a Jenkins Job name to an ObjectShift BuildConfig name- Parameters:
- jobName- the job to associate to a BuildConfig name
- namespace- the default namespace that Jenkins is running inside
- Returns:
- the namespaced name for the BuildConfig
 
- 
parseResourceVersionpublic static long parseResourceVersion(io.fabric8.kubernetes.api.model.HasMetadata obj) 
- 
parseResourceVersion
- 
formatTimestamp
- 
parseTimestamp
- 
isResourceWithoutStateEqualpublic static boolean isResourceWithoutStateEqual(io.fabric8.kubernetes.api.model.HasMetadata oldObj, io.fabric8.kubernetes.api.model.HasMetadata newObj) 
- 
dumpWithoutRuntimeStateAsYamlpublic static String dumpWithoutRuntimeStateAsYaml(io.fabric8.kubernetes.api.model.HasMetadata obj) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
- com.fasterxml.jackson.core.JsonProcessingException
 
- 
isCancellablepublic static boolean isCancellable(io.fabric8.openshift.api.model.BuildStatus buildStatus) 
- 
isNewpublic static boolean isNew(io.fabric8.openshift.api.model.BuildStatus buildStatus) 
- 
isCancelledpublic static boolean isCancelled(io.fabric8.openshift.api.model.BuildStatus status) 
- 
getLabel
- 
getAnnotation
- 
addAnnotation
- 
getNamespace
- 
getName
- 
getOpenshiftClientprotected static io.fabric8.openshift.client.OpenShiftClient getOpenshiftClient()
 
-