Wiki source code of Push Artifacts

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

Show last authors
1 The [[doc:Jenkins.Jenkins Shared Library.WebHome]] will build container images and Helm charts if the matching sources are found in the git Repository.
2
3 By default, the image and chart will be pushed by the [[doc:Jenkins.Jenkins Shared Library.WebHome]] to the same project inside the Docker registry and the Helm registry using the [[doc:Jenkins.Automatically provided Credentials.WebHome]].
4
5 This can be changed, if you want to push to another project or a target ouside of your DevOps-as-a-Servivce instance.
6
7 = Push to other project =
8
9 == Create technical user ==
10
11 Go to the DevOps portal and create a technical user in Nexus. Save the password in a secure place.
12
13 Then assign a DEVELOPER role to the technical user for the project which you want to use as a target.
14
15 The example screenshot shows a user called "devopsaas_publish_nexus" with DEVELOPER role in project "DevOps as a Service".
16
17 [[image:attach:image-2023-5-23_13-24-7.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" height="87" width="475"]]
18
19 To do the same for [[doc:Harbor.WebHome]] instead of Nexus use [[doc:Harbor.Harbor 2\.7 Robot Accounts.WebHome]].
20
21 == Create credentials on Jenkins ==
22
23 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.
24
25 [[image:attach:image-2024-3-15_15-39-2.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" height="236" width="475"]]
26
27 The following screenshot shows the header of the credential page for the example project "T-Solar Showcase".
28
29 [[image:attach:image-2024-3-15_16-52-46.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" height="72" width="475"]]
30
31 Now press "Add Credentials" and add username and password of the technical user.
32
33 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.
34
35 [[image:attach:image-2023-5-23_13-31-58.png||data-xwiki-image-style-border="true" queryparams="effects=drop-shadow" height="266" width="475"]]
36
37 == Adapt sdcPipeline() call ==
38
39 In your [[doc:Jenkins.Jenkinsfile.WebHome]] adapt the call of sdcPipeline() by adding some arguments as documented at [[doc:Jenkins.Jenkins Shared Library.WebHome]].
40
41 {{code language="groovy"}}
42 sdcPipeline(
43 // target project for docker image
44 imagePath: "devopsaas",
45
46 // credentials for pushing docker image
47 pushDockerRegistryCredentialsId: "devopsaas_publish_nexus",
48
49 // target Helm registry including project path, adjust CUSTOMER to your instance
50 helmRegistry: "https://CUSTOMER.devops.t-systems.net/nexus/repository/devopsaas-helm/",
51
52 // credentials for pushing Helm chart
53 helmRegistryCredentialsId: "devopsaas_publish_nexus",
54 )
55 {{/code}}
56
57 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.