Commit ea815750 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'fix-netrc-job-token' into 'master'

add implicit declaration of Job Token

See merge request to-be-continuous/ansible!84
parents a62978df 70d4f9bf
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -615,13 +615,21 @@ stages:
    fi
  }

  function maybe_install_requirements() {
  function configure_netrc() {
    # maybe install .netrc
    if [[ -f ".netrc" ]]; then
      log_info "--- \\e[32m.netrc\\e[0m file found: envsubst and install"
      tbc_envsubst .netrc > ~/.netrc
      chmod 0600 ~/.netrc
    else
      # Use CI job token to authenticate
      log_info "--- configure \\e[32m.netrc\\e[0m with CI job token"
      echo -e "machine ${CI_SERVER_HOST}\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" >> ~/.netrc
    fi
    chmod 0600 ~/.netrc
  }

  function maybe_install_requirements() {
    configure_netrc
    if [ -f "$ANSIBLE_REQUIREMENTS_FILE" ]
    then
      log_info "--- \\e[32mrequirements\\e[0m file (\\e[33;1m${ANSIBLE_REQUIREMENTS_FILE}\\e[0m) found: running \\e[33;1mansible-galaxy install\\e[0m"