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 Jenkins credentials import #48

Closed samuelbernardolip closed 3 years ago

samuelbernardolip commented 4 years ago

For 2.1.0 current implementation environment is required to pass credentials, but we can try to improve it using a special environment definition to set credentials and then pass it as environment.

Jenkins allows to import credentials using withCredentials wrapper step. For the most generic purpose we already have support for tokens (string), tuple username and password, file, zip and certificate. This secrets can be imported from Jenkins Credentials store.

For that we can improve current release to allow the following:

config:
  project_repos:
    worsica-processing:
      repo: 'https://github.com/WORSICA/worsica-processing.git'
      branch: master
      dockerhub: worsica/worsica-processing
      dockertag: latest
  credentials:
    - type: string
      credentialsId: "myGithubCredentials"
      variable: "GITHUB_TOKEN"
    - type: string
      credentialsId: "myGithubCredentials2"
      variable: "GITHUB_TOKEN2"

sqa-criteria:
  qc-style:
    repos:
      worsica-processing:
        container: processing
        environment:
          - GITHUB_TOKEN: "${GITHUB_TOKEN}"
          - GITHUB_TOKEN2: "${GITHUB_TOKEN2}"
        tox:
          testenv:
            - stylecheck

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

timeout: 600
samuelbernardolip commented 3 years ago

Already implemented and merged in release/2.1.0.