简体   繁体   English

我可以在成功构建 travis CI 后运行脚本吗?

[英]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.在 Travis CI 中成功构建后,我正在尝试运行脚本。 the script makes a rest call.该脚本进行 rest 调用。 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.如果我在成功后部分的 travis.yml 文件中运行脚本,它只会识别第一行而不执行其他行。 The script has multiple lines and makes a curl call.该脚本有多行并进行 curl 调用。

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.这是 travis.yml 文件。

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 作业完成时(无论是绿色还是红色)分配给该特定作业的 VM 将被终止,因此在您的.travis.yml文件之外这似乎是不可能的。

-- Travis CI staff -- Travis CI 员工

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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