configuration-as-code-plugin icon indicating copy to clipboard operation
configuration-as-code-plugin copied to clipboard

Support env variable to point jenkins.yaml location

Open ewelinawilkosz opened this issue 8 years ago • 15 comments

on praqma/dev branch we have implemented support for reading location of jenkins.yaml file from environment variable, that can point to local file, or repository - maybe it's time to move this functionality to master branch?

ewelinawilkosz avatar Dec 08 '17 09:12 ewelinawilkosz

I think it makes perfect sense.

ndeloof avatar Jan 10 '18 15:01 ndeloof

there are two options then - merge changes from praqma/dev or reimplement manually for now we want to support with env variable:

  1. location on disk
  2. location in git repository - raw file, or different solution, we can discuss it

in the future we can extend possible locations

ewelinawilkosz avatar Jan 21 '18 11:01 ewelinawilkosz

@ewelinawilkosz @ndeloof I think this a good one to start with. I'll start working on this tomorrow.

For the simple version, let's support URI's that can either be a file (locally), or some statically served file (I.E a gist). That should support most usecases i can re-use much from the implementation on Praqma's fork.

MadsNielsen avatar Jan 22 '18 13:01 MadsNielsen

Could we please get this right from the start and at least reject plain HTTP URLs?

daniel-beck avatar Jan 23 '18 09:01 daniel-beck

@daniel-beck Sure no problem :)

MadsNielsen avatar Jan 23 '18 09:01 MadsNielsen

I'm not a big fan enforcing https. This would make test/demo environment harder to setup, and for internal use I would expect many user will use plain old http.

ndeloof avatar Jan 23 '18 09:01 ndeloof

If we focus on security, I would expect configuration to be stored as a k8s ConfigMap / docker Config / some comparable "injected" content. This "pull" approach is just for basic usage

ndeloof avatar Jan 23 '18 09:01 ndeloof

@daniel-beck and @ndeloof Would a better approach to write some warning if you do use HTTP? Like a statement about that this should not be used in production?

I reckon im mostly gonna be use the path part of this feature, to start c-as-c with a configuration file outside my dev environment.

MadsNielsen avatar Jan 23 '18 09:01 MadsNielsen

Then maybe we just don't need http* support and should avoid introducing it here. Also, if we consider the other feature request to have multiple yaml files, better for this variable to point to a configuration folder.

ndeloof avatar Jan 23 '18 09:01 ndeloof

@ndeloof and @daniel-beck Ok. Let's do this then.

  1. We scrap http and https support.
  2. We instead take a path, it can either be a single file or a folder.
  3. In case of a folder we scan for all .yml|.yaml files in folder and return those to be configured. In case of a file just return that.

Sounds ok?

MadsNielsen avatar Jan 23 '18 09:01 MadsNielsen

see https://github.com/jenkinsci/configuration-as-code-plugin/issues/34

ndeloof avatar Jan 23 '18 09:01 ndeloof

Right i added my stuff for this to work with a very simple test. The big picture case in #34 is a superset of this task. I'll need to look up how k8 config maps etc work before i start comming up with suggestions on how this can be handled in a more generic and extensible way. But for now, it should be outside scope of this case :)

MadsNielsen avatar Jan 23 '18 10:01 MadsNielsen

docker config = a tmpfs folder mounted inside container:

docker run --config source=jenkins-config,target=/config/jenkins.yml ...

container can then read configuration from /config/jenkins.yaml

k8s config has more option, simplest for us is a volume mount (same as docker)

  containers:
    - name: jenkins
      volumeMounts:
      - name: jenkins-config
        mountPath: /config
  volumes:
    - name: jenkins-config
      configMap:
        name: jenkins-config

ndeloof avatar Jan 23 '18 11:01 ndeloof

Thanks @ndeloof and @MadsNielsen !

daniel-beck avatar Jan 23 '18 11:01 daniel-beck

Closing this issue PR merged and accepted

MadsNielsen avatar Jan 24 '18 08:01 MadsNielsen