title: Gitlab CICD sets wrong service url in the production environment
body: <p>After production deployment the application has not the endpoint of the environment.url from the <code>.gitlab-ci.yml</code>, but a combination of the groupname, projectname and basedomain:
  <code>&lt;groupname&gt;-&lt;projectname&gt;.basedomain</code>.</p>
  <p>The Gitlab project belongs to a Gitlab group, which has an Kubernetes cluster. De group has a basedomain which is used in the <code>.gitlab-ci.yml</code>:</p>
  <pre><code>//part of .gitlab-ci.yml
  
  ... 
  
  apply production secret configuration:
      stage: prepare-deploy
      extends: .auto-deploy
      needs: [&quot;build&quot;, &quot;generate production configuration&quot;]
      dependencies:
          - generate production configuration
      script:
          - auto-deploy check_kube_domain
          - auto-deploy download_chart
          - auto-deploy ensure_namespace
          - kubectl create secret generic tasker-secrets-development --from-file=config.tar --dry-run -o yaml | kubectl apply -f -
      environment:
          name: production
          url: http://app.$KUBE_INGRESS_BASE_DOMAIN
          action: prepare
      rules:
          - if: '$CI_COMMIT_BRANCH == &quot;master&quot;'
  
  ...  
  </code></pre>
  <p>I expected <code>http://app.$KUBE_INGRESS_BASE_DOMAIN</code> as the endpoint for the application.</p>
  <p>The Ingress (I removed the minio part):</p>
  <pre><code>
  
  apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: {{ template &quot;fullname&quot; . }}
    labels:
      app: {{ template &quot;appname&quot; . }}
      chart: &quot;{{ .Chart.Name }}-{{ .Chart.Version| replace &quot;+&quot; &quot;_&quot; }}&quot;
      release: {{ .Release.Name }}
      heritage: {{ .Release.Service }}
    annotations:
      cert-manager.io/cluster-issuer: {{ .Values.leIssuer }}
      acme.cert-manager.io/http01-edit-in-place: &quot;true&quot;
  {{- if .Values.ingress.annotations }}
  {{ toYaml .Values.ingress.annotations | indent 4 }}
  {{- end }}
  {{- with .Values.ingress.modSecurity }}
  {{- if .enabled }}
      nginx.ingress.kubernetes.io/modsecurity-transaction-id: &quot;$server_name-$request_id&quot;
      nginx.ingress.kubernetes.io/modsecurity-snippet: |
        SecRuleEngine {{ .secRuleEngine | default &quot;DetectionOnly&quot; | title }}
  {{- range $rule := .secRules }}
  {{ (include &quot;secrule&quot; $rule) | indent 6 }}
  {{- end }}
  {{- end }}
  {{- end }}
  {{- if .Values.prometheus.metrics }}
      nginx.ingress.kubernetes.io/server-snippet: |-
        location /metrics {
            deny all;
        }
  
  {{- end }}
  spec:
  {{- if .Values.ingress.tls.enabled }}
    tls:
    - hosts:
  {{- if .Values.service.commonName }}
      - {{ template &quot;hostname&quot; .Values.service.commonName }}
  {{- end }}
      - {{ template &quot;hostname&quot; .Values.service.url }} &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
  {{- if .Values.service.additionalHosts }}
  {{- range $host := .Values.service.additionalHosts }}
      - {{ $host }}
  {{- end -}}
  {{- end }}
      secretName: {{ .Values.ingress.tls.secretName | default (printf &quot;%s-cert&quot; (include &quot;fullname&quot; .)) }}
  {{- end }}
    rules:
    - host: {{ template &quot;hostname&quot; .Values.service.url }} &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
      http:
        &amp;httpRule
        paths:
        - path: /
          backend:
            serviceName: {{ template &quot;fullname&quot; . }}
            servicePort: {{ .Values.service.externalPort }}
  {{- if .Values.service.commonName }}
    - host: {{ template &quot;hostname&quot; .Values.service.commonName }}
      http:
        &lt;&lt;: *httpRule
  {{- end -}}
  {{- if .Values.service.additionalHosts }}
  {{- range $host := .Values.service.additionalHosts }}
    - host: {{ $host }}
      http:
        &lt;&lt;: *httpRule
  {{- end -}}
  {{- end -}}
  
  
  
  </code></pre>
  <p>What I have done so far:</p>
  <ul>
  <li>removed deployment from cluster, cleared the Gitlab runners cache, cleared the Gitlab cluster cache. Deleted the environment (stop and delete). Created a new environment 'production' with the right URL 'Operations&gt;Environments&gt;production&gt;Edit'. After push the url has been replaced with the wrong one.</li>
  <li>hard coded the url in Ingress (at the arrows in the snippet), it worked</li>
  <li>changed the value in gitlab-ci.yml without http://. No result.</li>
  <li>check the use of 'apply production secret configuration' in the gitlab-ci.yml, by adding echo 'message!'. Conclusion: this part of the file is used for production</li>
  <li>A CICD variable Settings&gt;CICD: GITLAB_ENVIRONMENT_URL. No effect.</li>
  </ul>
  <p>UPDATE:
  Maybe the <code>.Values.gitlab.app</code> is used for the URL.</p>