Skip to content

Commit

Permalink
Hook up Jenkins docker registry credentials if docker.registry.creden…
Browse files Browse the repository at this point in the history
…tial_id provided
  • Loading branch information
andytson-inviqa committed Mar 14, 2023
1 parent b2ee54e commit f8eaf5a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/_base/application/overlay/Jenkinsfile.twig
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ pipeline {
{% if bool(@('pipeline.publish.enabled')) %}
stage('Publish') {
{% set env = @('pipeline.publish.environment') %}
{% set docker_registry_credential_id = @('docker.registry.credential_id') %}
{% set ssh_credential_id = @('pipeline.publish.chart.git.ssh_credential_id') %}
{% if env or ssh_credential_id %}
{% if env or docker_registry_credential_id or ssh_credential_id %}
environment {
{% for key, value in env %}
{{ key }} = {{ value }}
{% endfor %}
{% if docker_registry_credential_id %}
DOCKER_REGISTRY_CREDS = credentials('{{ docker_registry_credential_id }}')
{% endif %}
{% if ssh_credential_id %}
WS_APP_PUBLISH_CHART_SSH_PRIVATE_KEY = credentials('{{ ssh_credential_id }}')
{% endif %}
Expand Down
7 changes: 5 additions & 2 deletions src/_base/harness/attributes/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ attributes.default:
docker:
registry:
url: = get_docker_registry(@('docker.repository'))
username: = @('docker.username') # for backwards compatibility
password: = @('docker.password') # for backwards compatibility
# A Username with Password Jenkins credential id
# Preferred over .username/.password to store credentials local development doesn't need
credential_id: ~
username: "= env('DOCKER_REGISTRY_CREDS_USR') ?: null"
password: "= env('DOCKER_REGISTRY_CREDS_PSW') ?: null"
repository: = @("workspace.name")
buildkit:
enabled: true
Expand Down

0 comments on commit f8eaf5a

Please sign in to comment.