You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thank you for providing an example on how to get the runner token in a .sh script. A few days ago it was working like a charm, however when running it today I noticed the second body_header variable is empty. Upon inspecting the gitlab-header.txt file, I noticed it contained:
Whereas I would expect it to be signed in at that point, with a gitlab-header.txt file that contains the respective runner registration token. I expect I am doing something wrong, however, perhaps there has been an update to the gitlab/gitlab-ce:latest package such that a change to the script is required.
For completeness, I hardcoded the email, username and password, and manually verified I was able to log into the GitLab server with those credentials:
GITURL="$GITLAB_SERVER_HTTP_URL"
GITUSER="$gitlab_server_account"
GITROOTPWD="$gitlab_server_password"
echo "GITUSER=$GITUSER"
echo "GITROOTPWD=$GITROOTPWD"
# 1. curl for the login page to get a session cookie and the sources with the auth tokens
body_header=$(curl -k -c gitlab-cookies.txt -i "${GITURL}/users/sign_in" -sS)
# grep the auth token for the user login for
# not sure whether another token on the page will work, too - there are 3 of them
csrf_token=$(echo $body_header | perl -ne 'print "$1\n" if /new_user.*?authenticity_token"[[:blank:]]value="(.+?)"/' | sed -n 1p)
# 2. send login credentials with curl, using cookies and token from previous request
curl -sS -k -b gitlab-cookies.txt -c gitlab-cookies.txt "${GITURL}/users/sign_in" \
--data "user[login]=${GITUSER}&user[password]=${GITROOTPWD}" \
--data-urlencode "authenticity_token=${csrf_token}" -o /dev/null
# 3. send curl GET request to gitlab runners page to get registration token
body_header=$(curl -sS -k -H 'user-agent: curl' -b gitlab-cookies.txt "${GITURL}/admin/runners" -o gitlab-header.txt)
reg_token=$(cat gitlab-header.txt | perl -ne 'print "$1\n" if /code id="registration_token">(.+?)</' | sed -n 1p)
echo $reg_token
The text was updated successfully, but these errors were encountered:
Hi, thank you for providing an example on how to get the runner token in a
.sh
script. A few days ago it was working like a charm, however when running it today I noticed the secondbody_header
variable is empty. Upon inspecting thegitlab-header.txt
file, I noticed it contained:Whereas I would expect it to be signed in at that point, with a
gitlab-header.txt
file that contains the respectiverunner registration token
. I expect I am doing something wrong, however, perhaps there has been an update to thegitlab/gitlab-ce:latest
package such that a change to the script is required.For completeness, I hardcoded the email, username and password, and manually verified I was able to log into the GitLab server with those credentials:
The text was updated successfully, but these errors were encountered: