简体   繁体   中英

Can i run a script after a successful build in travis CI?

I am trying to run a script after a successful build in Travis CI. the script makes a rest call. If I run the script in the travis.yml file in the after-success part it is recognizing only the first line and not executing the other lines. The script has multiple lines and makes a curl call.

sudo: required
language: java

script: mvn org.codehaus.mojo:license-maven-plugin:download-licenses

env-variable:
-BEARER
-SYNC_RUN
-RES

after_success:
- BEARER=$(curl -X POST --url https://example.com -u apitoken:1234567890 --data grant_type=client_credentials | jq -r '.access_token')
- SYNC_RUN=$(curl -X POST --header 'Content-Type: application/json' --header "Authorization: Bearer $BEARER" -d "`cat pivio.yaml`" https://example.com | jq -r '.id')
- RES=$(curl --write-out '%{http_code}' -X POST --header 'Content-Type: application/json' --header "Authorization: Bearer $BEARER" https://example.com/$SYNC_RUN/start)
services:
  - docker

This is the travis.yml file.

When the Travis CI job, finishes(regardless of green or red) the VM assigned for that specific job is getting terminated so this won't seem possible outside of your .travis.yml file.

-- Travis CI staff

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM