Skip to content

Commit

Permalink
NO-ISSUE: Fix publishing KIE Sandbox helm chart to Docker Hub (apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigonull authored Jul 4, 2024
1 parent 5372b59 commit 1f33734
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .ci/jenkins/Jenkinsfile.daily-dev-publish
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ pipeline {
dir('kie-tools') {
script {
helmUtils.pushChartToRegistry(
"${env.KIE_SANDBOX_HELM_CHART__registry}/${env.KIE_SANDBOX_HELM_CHART__account}",
"${env.KIE_SANDBOX_HELM_CHART__registry}",
"${env.KIE_SANDBOX_HELM_CHART__account}",
"packages/kie-sandbox-helm-chart/dist/${env.KIE_SANDBOX_HELM_CHART__name}-${env.KIE_SANDBOX_HELM_CHART__tag}.tgz",
"${pipelineVars.dockerHubUserCredentialsId}",
"${pipelineVars.dockerHubTokenCredentialsId}"
Expand Down
3 changes: 2 additions & 1 deletion .ci/jenkins/release-jobs/Jenkinsfile.kie-sandbox-helm-chart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ pipeline {
dir('kie-tools') {
script {
helmUtils.pushChartToRegistry(
"${env.KIE_SANDBOX_HELM_CHART__registry}/${env.KIE_SANDBOX_HELM_CHART__account}",
"${env.KIE_SANDBOX_HELM_CHART__registry}",
"${env.KIE_SANDBOX_HELM_CHART__account}",
"packages/kie-sandbox-helm-chart/dist/${env.KIE_SANDBOX_HELM_CHART__name}-${env.KIE_SANDBOX_HELM_CHART__tag}.tgz",
"${pipelineVars.dockerHubUserCredentialsId}",
"${pipelineVars.dockerHubTokenCredentialsId}"
Expand Down
6 changes: 3 additions & 3 deletions .ci/jenkins/shared-scripts/dockerUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
* Push an image to a given registry
*/
def pushImageToRegistry(String registry, String account, String image, String tags, String userCredentialsId, String tokenCredentialsId) {
withCredentials([string(credentialsId: userCredentialsId, variable: 'DOCKER_USER')]) {
withCredentials([string(credentialsId: tokenCredentialsId, variable: 'DOCKER_TOKEN')]) {
withCredentials([string(credentialsId: userCredentialsId, variable: 'REGISTRY_USER')]) {
withCredentials([string(credentialsId: tokenCredentialsId, variable: 'REGISTRY_TOKEN')]) {
sh """
echo "${DOCKER_TOKEN}" | docker login -u "${DOCKER_USER}" --password-stdin $registry
echo "${REGISTRY_TOKEN}" | docker login -u "${REGISTRY_USER}" --password-stdin $registry
""".trim()
tagList = tags.split(' ')
for (tag in tagList) {
Expand Down
14 changes: 9 additions & 5 deletions .ci/jenkins/shared-scripts/helmUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
/**
* Push a Helm Chart to a given registry
*/
def pushChartToRegistry(String registry, String chart, String credentialsId) {
withCredentials([usernamePassword(credentialsId: credentialsId, usernameVariable: 'REGISTRY_USER', passwordVariable: 'REGISTRY_PWD')]) {
sh "set +x && helm registry login -u $REGISTRY_USER -p $REGISTRY_PWD $registry"
sh "helm push ${chart} oci://${registry}"
sh "helm registry logout ${registry}"
def pushChartToRegistry(String registry, String account, String chart, String userCredentialsId, String tokenCredentialsId) {
withCredentials([string(credentialsId: userCredentialsId, variable: 'REGISTRY_USER')]) {
withCredentials([string(credentialsId: tokenCredentialsId, variable: 'REGISTRY_TOKEN')]) {
sh """
echo "${REGISTRY_TOKEN}" | helm registry login -u "${REGISTRY_USER}" --password-stdin $registry
helm push ${chart} oci://${registry}/${account}
helm registry logout ${registry}
""".trim()
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/kie-sandbox-helm-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,27 +168,27 @@ Very similar to the way you install the chart from source code, you can also ins
### Default install

```console
$ helm install kie-sandbox oci://docker.io/apache/incubator-kie-sandbox-helm-chart --version=0.0.0
$ helm install kie-sandbox oci://docker.io/apache/incubator-kie-sandbox-helm-chart --version=0.0.0-main
```

### Minikube install

```console
$ helm pull oci://docker.io/apache/incubator-kie-sandbox-helm-chart --version=0.0.0 --untar
$ helm pull oci://docker.io/apache/incubator-kie-sandbox-helm-chart --version=0.0.0-main --untar
$ helm install kie-sandbox ./kie-sandbox-helm-chart --values ./kie-sandbox-helm-chart/values-minikube-nginx.yaml
```

### Kubernetes install

```console
$ helm pull oci://docker.io/apache/incubator-kie-sandbox-helm-chart --version=0.0.0 --untar
$ helm pull oci://docker.io/apache/incubator-kie-sandbox-helm-chart --version=0.0.0-main --untar
$ helm install kie-sandbox ./kie-sandbox-helm-chart --values ./kie-sandbox-helm-chart/values-kubernetes.yaml --set global.kubernetesClusterDomain="<YOUR_KUBERNETES_CLUSTER_DOMAIN>" --set global.kubernetesIngressClass="<YOUR_KUBERNETES_INGRESS_CLASS>"
```

### OpenShift install

```console
$ helm pull oci://docker.io/apache/incubator-kie-sandbox-helm-chart --version=0.0.0 --untar
$ helm pull oci://docker.io/apache/incubator-kie-sandbox-helm-chart --version=0.0.0-main --untar
$ helm install kie-sandbox ./kie-sandbox-helm-chart --values ./kie-sandbox-helm-chart/values-openshift.yaml --set global.openshiftRouteDomain="<YOUR_OCP_ROUTE_DOMAIN>"
```

Expand Down
3 changes: 3 additions & 0 deletions packages/kie-sandbox-helm-chart/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const chartFiles = [
];
chartFiles.forEach((file) => {
const doc = yaml.parseDocument(fs.readFileSync(file, "utf8"));
if (file == "src/Chart.yaml") {
doc.setIn(["name"], env.kieSandboxHelmChart.name);
}
doc.setIn(["version"], env.kieSandboxHelmChart.tag);
doc.setIn(["appVersion"], env.kieSandboxHelmChart.tag);
if (doc.getIn(["dependencies"])) {
Expand Down
2 changes: 1 addition & 1 deletion packages/kie-sandbox-helm-chart/src/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: kie-sandbox-helm-chart
name: incubator-kie-sandbox-helm-chart
description: A Helm chart to deploy KIE Sandbox and related services on Kubernetes
type: application
version: 0.0.0
Expand Down
2 changes: 1 addition & 1 deletion packages/kie-sandbox-helm-chart/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
under the License.
-->

# kie-sandbox-helm-chart
# incubator-kie-sandbox-helm-chart

![Version: 0.0.0](https://img.shields.io/badge/Version-0.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.0.0](https://img.shields.io/badge/AppVersion-0.0.0-informational?style=flat-square)

Expand Down

0 comments on commit 1f33734

Please sign in to comment.