0

What I'm trying to do is getting user's first name to be displayed ($GITLAB_USER_NAME variable stores users' names as: Lastname, Firstname, so e.g. Jones, Indiana):

deploy_to_server:
  stage: deploy
  when: manual
  script:
    - touch report.txt
    - printf "Hello $($GITLAB_USER_NAME | awk '{ print $2 }').\n" >> report.txt
    - cat report.txt

Any clue how to process the variable with awk so that it gives the desired output, Hello Indiana?

1 Answer 1

1

It turns out, in this case printf could be replaced with echo:

deploy_to_server:
  stage: deploy
  when: manual
  script:
    - touch report.txt
    - echo "Hello $GITLAB_USER_NAME" | awk '{ print $1 " " $3 ".\n\n" }' >> report.txt
    - cat report.txt

awk takes the first and the third column from the echoed string ([1]Hello [2]Jones, [3]Indiana), then I also added a space between words, and period followed by two newline characters.

In the end, the whole printout looks like this:

Hello Indiana.


Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.