Commit ce2012e4 authored by Cédric OLIVIER's avatar Cédric OLIVIER Committed by Pierre Smeyers
Browse files

fix: permission problem on chmod

parent 519a1d1c
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -200,6 +200,8 @@ The deployment script is searched as follows:
2. if not found: look for a default `k8s-deploy.sh` in the `$K8S_SCRIPTS_DIR` directory in your project,
3. if not found: the GitLab CI template assumes you're using the template-based deployment policy.

:warning: `k8s-deploy-$env.sh` or `k8s-deploy.sh` needs to be executable, you can add flag execution with :  `git update-index --chmod=+x k8s-deploy.sh`

Your script(s) may use [dynamic variables](#dynamic-variables).

#### 2: template-based deployment
@@ -214,7 +216,9 @@ The template processes the following steps:
    1. look for a specific `deployment-$env.yml` in your project (e.g. `deployment-staging.yml` for staging environment),
    2. fallbacks to default `deployment.yml`.
3. _optionally_ executes the `k8s-post-apply.sh` script in your project to perform specific environment post-initialization stuff,
4. _optionally_ executes the `k8s-readiness-check` to wait & check for the application to be ready (if not found, the template assumes the application was successfully started).
4. _optionally_ executes the `k8s-readiness-check.sh` to wait & check for the application to be ready (if not found, the template assumes the application was successfully started).

:warning: `k8s-pre-apply.sh`,`k8s-post-apply.sh` or `k8s-readiness-check.sh` needs to be executable, you can add flag execution with :  `git update-index --chmod=+x k8s-pre-apply.sh`

All scripts and Kubernetes deployment files may use [dynamic variables](#dynamic-variables).

@@ -235,6 +239,8 @@ The a deployment script is searched as follows:
2. if not found: look for a default `k8s-cleanup.sh` in the `$K8S_SCRIPTS_DIR` directory in your project,
3. if not found: the GitLab CI template assumes you're using the template-based cleanup policy.

:warning: `k8s-cleanup-$env.sh` or `k8s-cleanup.sh` needs to be executable, you can add flag execution with :  `git update-index --chmod=+x k8s-cleanup.sh`

Your script(s) may use [dynamic variables](#dynamic-variables).

> TIP: a nice way to implement environment cleanup is to declare the label `app=${appname}` on every Kubernetes
@@ -253,6 +259,8 @@ The template processes the following steps:
    2. fallbacks to default `deployment.yml`.
3. _optionally_ executes the `k8s-post-cleanup.sh` script in your project to perform specific environment post-cleanup (for e.g. delete bound services).

:warning: `k8s-pre-cleanup.sh` or `k8s-post-cleanup.sh` needs to be executable, you can add flag execution with :  `git update-index --chmod=+x k8s-pre-cleanup.sh`

All scripts and Kubernetes deployment files may use [dynamic variables](#dynamic-variables).

#### Cleanup job limitations
+19 −18
Original line number Diff line number Diff line
@@ -239,6 +239,16 @@ stages:
    awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);val=ENVIRON[var];gsub(/["\\]/,"\\\\&", val);gsub("\n", "\\n", val);gsub("\r", "\\r", val);gsub("[$]{"var"}",val)}}1'
  }

  function exec_hook() {
    if [[ ! -x "$1" ]] && ! chmod +x "$1"
    then
      log_warn "... could not make \\e[33;1m${1}\\e[0m executable: please do it (chmod +x)"
      # fallback technique
      sh "$1"
    else
      "$1"
    fi
  }
  function login() {
    env=$1
    url=$2
@@ -313,8 +323,7 @@ stages:
    if [[ -f "$deployscript" ]]
    then
      log_info "--- deploy script (\\e[33;1m${deployscript}\\e[0m) found: execute"
      chmod +x "$deployscript"
      "$deployscript"
      exec_hook "$deployscript"
    else
      log_info "--- no deploy script found: run template-based deployment"

@@ -322,8 +331,7 @@ stages:
      prescript="$K8S_SCRIPTS_DIR/k8s-pre-apply.sh"
      if [[ -f "$prescript" ]]; then
        log_info "--- \\e[32mpre-apply hook\\e[0m (\\e[33;1m${prescript}\\e[0m) found: execute"
        chmod +x "$prescript"
        "$prescript"
        exec_hook "$prescript"
      else
        log_info "--- \\e[32mpre-apply hook\\e[0m (\\e[33;1m${prescript}\\e[0m) not found: skip"
      fi
@@ -347,8 +355,7 @@ stages:
      postscript="$K8S_SCRIPTS_DIR/k8s-post-apply.sh"
      if [[ -f "$postscript" ]]; then
        log_info "--- \\e[32mpost-apply hook\\e[0m (${postscript}) found: execute"
        chmod +x "$postscript"
        "$postscript"
        exec_hook "$postscript"
      else
        log_info "--- \\e[32mpost-apply hook\\e[0m (${postscript}) not found: skip"
      fi
@@ -362,8 +369,7 @@ stages:
    readycheck="$K8S_SCRIPTS_DIR/k8s-readiness-check.sh"
    if [[ -f "$readycheck" ]]; then
      log_info "--- \\e[32mreadiness-check hook\\e[0m (\\e[33;1m${readycheck}\\e[0m) found: execute"
      chmod +x "$readycheck"
      "$readycheck"
      exec_hook "$readycheck"
    else
      log_info "--- \\e[32mreadiness-check hook\\e[0m (\\e[33;1m${readycheck}\\e[0m) not found: assume app is ready"
    fi
@@ -396,8 +402,7 @@ stages:
    prescript="$K8S_SCRIPTS_DIR/k8s-pre-rollback.sh"
    if [[ -f "$prescript" ]]; then
      log_info "--- \\e[32mpre-rollback hook\\e[0m (\\e[33;1m${prescript}\\e[0m) found: execute"
      chmod +x "$prescript"
      "$prescript"
      exec_hook "$prescript"
    else
      log_info "--- \\e[32mpre-rollback hook\\e[0m (\\e[33;1m${prescript}\\e[0m) not found: skip"
    fi
@@ -411,8 +416,7 @@ stages:
    postscript="$K8S_SCRIPTS_DIR/k8s-post-rollback.sh"
    if [[ -f "$postscript" ]]; then
      log_info "--- \\e[32mpost-rollback hook\\e[0m (\\e[33;1m${postscript}\\e[0m) found: execute"
      chmod +x "$postscript"
      "$postscript"
      exec_hook "$postscript"
    else
      log_info "--- \\e[32mpost-rollback hook\\e[0m (\\e[33;1m${postscript}\\e[0m) not found: skip"
    fi
@@ -441,8 +445,7 @@ stages:
    if [[ -f "$cleanupscript" ]]
    then
      log_info "--- cleanup script (\\e[33;1m${cleanupscript}\\e[0m) found: execute"
      chmod +x "$cleanupscript"
      "$cleanupscript"
      exec_hook "$cleanupscript"
    else
      log_info "--- no cleanup script found: proceed with template-based delete"

@@ -450,8 +453,7 @@ stages:
      prescript="$K8S_SCRIPTS_DIR/k8s-pre-cleanup.sh"
      if [[ -f "$prescript" ]]; then
        log_info "--- \\e[32mpre-cleanup hook\\e[0m (\\e[33;1m${prescript}\\e[0m) found: execute"
        chmod +x "$prescript"
        "$prescript"
        exec_hook "$prescript"
      else
        log_info "--- \\e[32mpre-cleanup hook\\e[0m (\\e[33;1m${prescript}\\e[0m) not found: skip"
      fi
@@ -478,8 +480,7 @@ stages:
      postscript="$K8S_SCRIPTS_DIR/k8s-post-cleanup.sh"
      if [[ -f "$postscript" ]]; then
        log_info "--- \\e[32mpost-cleanup hook\\e[0m (\\e[33;1m${postscript}\\e[0m) found: execute"
        chmod +x "$postscript"
        "$postscript"
        exec_hook "$postscript"
      else
        log_info "--- \\e[32mpost-cleanup hook\\e[0m (\\e[33;1m${postscript}\\e[0m) not found: skip"
      fi