Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Travis-CI, how to get committer_email, author_name, within after_script command

I know committer_email, author_name, and load of other variables are part of the notification event. Is it possible to get access to them in earlier events like before_script, after_script?

I would like to get access of the information and add it directly to my test results. Having build information, test result information, and github repo information in the same file would be great.

like image 431
iWarrior Avatar asked Sep 24 '16 22:09

iWarrior


People also ask

How do you trigger Travis CI?

Trigger Travis CI builds using the API V3 by sending a POST request to /repo/{slug|id}/requests : Get an API token from your Travis CI settings page. You'll need the token to authenticate most of these API requests.

What is Travis Yml file?

travis. yml , which is a YAML format text file, to the root directory of the repository. This file specifies the programming language used, the desired building and testing environment (including dependencies which must be installed before the software can be built and tested), and various other parameters.


1 Answers

You can extract committer e-mail, author name, etc. to environment variables using git log with --pretty, e.g.

export COMMITTER_EMAIL="$(git log -1 $TRAVIS_COMMIT --pretty="%cE")"
export AUTHOR_NAME="$(git log -1 $TRAVIS_COMMIT --pretty="%aN")"

On Travis one'd put this in the before_install or before_script stage.

TRAVIS_COMMIT environment variable is provided by default.

like image 182
набиячлэвэли Avatar answered Oct 13 '22 07:10

набиячлэвэли