Push Artifacts

Last modified by DevOps-as-a-Service Operator on 2025/02/05 11:33

The Jenkins Shared Library will build container images and Helm charts if the matching sources are found in the git Repository.

By default, the image and chart will be pushed by the Jenkins Shared Library to the same project inside the Docker registry and the Helm registry using the Automatically provided Credentials.

This can be changed, if you want to push to another project or a target ouside of your DevOps-as-a-Servivce instance.

Push to other project

Create technical user

Go to the DevOps portal and create a technical user in Nexus. Save the password in a secure place.

Then assign a DEVELOPER role to the technical user for the project which you want to use as a target.

The example screenshot shows a user called "devopsaas_publish_nexus" with DEVELOPER role in project "DevOps as a Service".

image-2023-5-23_13-24-7.png

To do the same for Harbor instead of Nexus use Harbor 2.7 Robot Accounts.

Create credentials on Jenkins

To get to the credentials of your project, go to the home page of the DevOps Portal, then click on Project Credentials in the Jenkins tile.

image-2024-3-15_15-39-2.png

The following screenshot shows the header of the credential page for the example project "T-Solar Showcase".

image-2024-3-15_16-52-46.png

Now press "Add Credentials" and add username and password of the technical user.

The ID will be used later to reference the credentials in the Jenkinsfile. It's always the easiest approach to use the username here, too.

image-2023-5-23_13-31-58.png

Adapt sdcPipeline() call

In your Jenkinsfile adapt the call of sdcPipeline() by adding some arguments as documented at Jenkins Shared Library.

sdcPipeline(
   // target project for docker image
   imagePath: "devopsaas",
   
   // credentials for pushing docker image
   pushDockerRegistryCredentialsId: "devopsaas_publish_nexus",
   
   // target Helm registry including project path, adjust CUSTOMER to your instance
   helmRegistry: "https://CUSTOMER.devops.t-systems.net/nexus/repository/devopsaas-helm/",
   
   // credentials for pushing Helm chart
   helmRegistryCredentialsId: "devopsaas_publish_nexus",
)

A similar approach would also work to push to Docker registries or Helm registries not operated by DevOps-as-a-Service. You just have to make sure that you have credentials to be used for pushing.