indigo-dc / jenkins-pipeline-library

Jenkins pipeline library with common functionalities for CI/CD environments, mainly targeted for the implementation of the SQA baseline requirements from https://indigo-dc.github.io/sqa-baseline/
Apache License 2.0
11 stars 6 forks source link

Support environment variables definitions into containers #47

Closed samuelbernardolip closed 4 years ago

samuelbernardolip commented 4 years ago

Release 2.0.0 already supports global environment definition that is imported in the beginning of the pipeline. For this release is proposed to improve to use config.env definitions to avoid code repetition. Also in sqa-criteria must be possible to import the environment for each container environment. The expected result would be for example:

config:
  project_repos:
    worsica-processing:
      repo: 'https://github.com/WORSICA/worsica-processing.git'
      branch: master
      dockerhub: worsica/worsica-processing
      dockertag: latest
  env:
    person2:
      GIT_COMMITTER_NAME: Person2
      GIT_COMMITTER_EMAIL: person2@example.org
    sqaenv:
      PROJECT: "xpto"
    qcstyle:
      LANGUAGE: "python"

sqa-criteria:
  environment:
    config:
      - sqaenv
    VAR1: "xpto1"
  qc-style:
    environment:
      config:
        - qcstyle
      VAR2: "sadges"
    repos:
      worsica-processing:
        environment:
          config:
            - person2
          VAR3: "aslkdas"
        container: processing
        tox:
          testenv:
            - stylecheck

environment:
  GIT_COMMITTER_NAME: Person1
  GIT_COMMITTER_EMAIL: person1@example.org
  LANG: C.UTF-8

timeout: 600

Note: environment over primary namespace doesn't apply to the containers and is used as library support for any internal configurations that user can customize for the plugins.

samuelbernardolip commented 4 years ago

Environment variables can be simplified into primary namespace environment (already implemented in release 2.0.0) and credentials in issue #48. Since we are not giving additional functionality value for config.yml, only repeating the definitions already available from agent context, it's better to keep it simple and define the variables for containers in agent configuration.

In current 2.0.0 release environment variables can be defined in docker-compose.yml for each deployed service/container.