RajeevKulkarni
RajeevKulkarni

Reputation: 1

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.

Upvotes: 0

Views: 111

Answers (1)

mergul
mergul

Reputation: 19

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

Upvotes: 0

Related Questions