fabric8-pipeline-library
fabric8-pipeline-library copied to clipboard
lets use the new API to query if a job name / branch name / gitUrl is a CI / CD / Developer pipeline
the current isCI()
and isCD()
functions should now delegate to a getPipeline()
helper method which should lazily invoke this code: https://github.com/fabric8io/fabric8/blob/master/components/kubernetes-api/src/main/java/io/fabric8/kubernetes/api/pipelines/Pipelines.java#L34
and cache the Pipeline object (transiently!) around for the lifetime of a job - lazily requerying if its null.
something kinda like...
def isCI(){
return getPipeline().isCI()
}
def isCD(){
return getPipeline().isCD()
}
// TODO not sure if this works ;) just trying to cache this value for later
def transient _pipeline: Pipeline = null;
def getPipeline() {
def kubernetes = new DefaultKubernetesClient()
def namespace = kubernetes.getNamespace()
// TODO ensure that BRANCH_NAME and GIT_URL are populated!
return io.fabric8.kubernetes.api.pipelines.Pipelines.getPipeline(kubernetes, namespace, env);
}