fabric8-pipeline-library icon indicating copy to clipboard operation
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

Open jstrachan opened this issue 7 years ago • 0 comments

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); 
}

jstrachan avatar Mar 13 '17 14:03 jstrachan