1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/resources/metadata/gitopsUpdateDeployment.yaml
Fabian Reh 04599e97da
feat(Gitops): Gitops update deployment with helm (#2247)
* makes containerImage not mandatory

* Adds kubectl container

* Adds log statement to debug

* adds general to container image

* removes GENERAL again
Removes condition from Kubectl container

* removes workDir

* marks logs as debug

* adds workingdir again

* Adds author to commits

* Adds commit time now

* remove deprecated and reorder

* adds deprecated again to containerRegistryUrl
Adds GENERAL scope to containerImage

* updates generated file

* Renames containerImageNameTag

* adds else case

* adds debug log

* code cleanup

* adds debug log

* revert

* adds debug logs

* revert

* makes root path not hidden

* revert

* Read container properties

* Removes debug message

* Removes debug message

* Removes general scope again

* Fixes unit test

* Adds helm capabilities to the gitopsUpdateDeployment step

* Adds helm capabilities to gitopsUpdateDeployment step

* Removes condition from input field

* Adds test for invalid deploy tool

* Fixes typo

* Adds tests for git errors and file errors
Simplifies test setup

* Adds test for error on image name extraction

* fixes URL variable name

* adds workind directory to paths

* Refactors too long method

* Reverts refactoring method

* Adds repository name as parameter

* Adds glob method

* Test glob method

* Revert "Test glob method"

This reverts commit ac11b54c14.

* Revert "Adds glob method"

This reverts commit ddf47ddebe.

* Revert "Adds repository name as parameter"

This reverts commit 8fc471c909.

* Removes getWd

* Adds stash deployDescriptor

* removes = from paramters

* Revert "removes = from paramters"

This reverts commit 3ecb3665e2.

* Adds " around parameters

* adds logging of all files

* Updates helm to version 3.3.4

* Clean up debug logs

* Raise error if no branch name provided.
Defaulting should be handled by step configuration.

* clean code

* Updates fields and adds checks for required field for certain deploy tools

* Fixes default commit message

* Update long description

* Removes default parameter

* Update resources/metadata/gitopsUpdateDeployment.yaml

Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>

* Updates yaml file

* Add error category and removes too much wrapping

* Update generated file

* Checks all parameters before returning the error

* Introduces constant

* Renames constant

* Fixes unit tests

* unexpose constants

* Makes tests thread safe and resilient to failed deletion

* Remove methods that did not work properly with hash containers rather than tags.

Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
2020-11-03 18:29:46 +01:00

182 lines
5.5 KiB
YAML

metadata:
name: gitopsUpdateDeployment
description: Updates Kubernetes Deployment Manifest in an Infrastructure Git Repository
longDescription: |
This step allows you to update the deployment manifest for Kubernetes in a git repository.
It can for example be used for GitOps scenarios where the update of the manifests triggers an update of the corresponding deployment in Kubernetes.
As of today, it supports the update of deployment yaml files via kubectl patch and update a whole helm template.
For kubectl the container inside the yaml must be described within the following hierarchy: `{"spec":{"template":{"spec":{"containers":[{...}]}}}}`
For helm the whole template is generated into a file and uploaded into the repository.
spec:
inputs:
secrets:
- name: gitHttpsCredentialsId
description: Jenkins 'Username with password' credentials ID containing username/password for http access to your git repository.
type: jenkins
resources:
- name: deployDescriptor
type: stash
params:
- name: branchName
description: The name of the branch where the changes should get pushed into.
scope:
- PARAMETERS
- STAGES
- STEPS
type: string
default: master
mandatory: true
- name: commitMessage
description: The commit message of the commit that will be done to do the changes.
longDescription: If the commit message is empty a default message in the form "Updated _containerName_ to version _containerImage_" will be used.
scope:
- PARAMETERS
- STAGES
- STEPS
type: string
- name: serverUrl
aliases:
- name: githubServerUrl
description: GitHub server url to the repository.
scope:
- GENERAL
- PARAMETERS
- STAGES
- STEPS
type: string
default: https://github.com
mandatory: true
- name: username
type: string
description: User name for git authentication
scope:
- PARAMETERS
- STAGES
- STEPS
mandatory: true
secret: true
resourceRef:
- name: gitHttpsCredentialsId
type: secret
param: username
- name: password
type: string
description: Password/token for git authentication.
scope:
- PARAMETERS
- STAGES
- STEPS
mandatory: true
secret: true
resourceRef:
- name: gitHttpsCredentialsId
type: secret
param: password
- name: filePath
description: Relative path in the git repository to the deployment descriptor file that shall be updated
scope:
- PARAMETERS
- STAGES
- STEPS
type: string
mandatory: true
- name: containerName
description: The name of the container to update
scope:
- PARAMETERS
- STAGES
- STEPS
type: string
- name: containerRegistryUrl
aliases:
- name: dockerRegistryUrl
type: string
mandatory: true
description: http(s) url of the Container registry where the image is located
scope:
- GENERAL
- PARAMETERS
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: container/registryUrl
- name: containerImageNameTag
aliases:
- name: image
deprecated: true
- name: containerImage
type: string
mandatory: true
description: Container image name with version tag to annotate in the deployment configuration.
scope:
- PARAMETERS
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: container/imageNameTag
- name: chartPath
aliases:
- name: helmChartPath
type: string
description: Defines the chart path for deployments using helm.
scope:
- PARAMETERS
- STAGES
- STEPS
- name: helmValues
type: "[]string"
description: List of helm values as YAML file reference or URL (as per helm parameter description for `-f` / `--values`)
scope:
- PARAMETERS
- STAGES
- STEPS
- name: deploymentName
aliases:
- name: helmDeploymentName
type: string
description: Defines the name of the deployment.
scope:
- PARAMETERS
- STAGES
- STEPS
# default: deployment
- name: tool
type: string
description: Defines the tool which should be used to update the deployment description.
mandatory: true
scope:
- PARAMETERS
- STAGES
- STEPS
default: kubectl
possibleValues:
- kubectl
- helm
containers:
- image: dtzar/helm-kubectl:3.3.4
workingDir: /config
options:
- name: -u
value: "0"
conditions:
- conditionRef: strings-equal
params:
- name: tool
value: helm
- image: dtzar/helm-kubectl:2.12.1
workingDir: /config
options:
- name: -u
value: "0"
conditions:
- conditionRef: strings-equal
params:
- name: tool
value: kubectl