MTJ
MTJ

Reputation: 1097

Azure DevOps pipeline set git user email from build variable

When pipeline is triggered by committer "Teppo Tulppu" "teppo.tulppu@duckburg" user.name ends up as Teppo.

Is this an Azure DevOps "feature" or can I fix this somehow?

  - task: Bash@3
    displayName: 'Set git config email & name'
    inputs:
      targetType: 'inline'
      script: |
        git config --global user.email $BUILD_REQUESTEDFOREMAIL
        git config --global user.name $BUILD_REQUESTEDFOR

Upvotes: 2

Views: 3325

Answers (1)

Frank Wang-MSFT
Frank Wang-MSFT

Reputation: 1407

This is not the Azure DevOps feature. This is some limits with git config command. If your username like "aa bb", and you input the command like git config --global user.name aa bb,user.name will only display letters which are before the space.

So you can change your script to below and then the user name will display as your expected.

git config --global user.email $BUILD_REQUESTEDFOREMAIL
git config --global user.name "$BUILD_REQUESTEDFOR"

Just use the specifal characters " to contain the predefined variable can fix this.

Upvotes: 4

Related Questions