[英]Travis CI After Success Write to a File in GitHub Repo
我有以下脚本,我开始在我使用 Travis CI 的一个项目中编写它。
after_success:
- MESSAGE=$(git log --format=%B -n 1 $TRAVIS_BUILD_NUMBER)
- git clone git://${GH_REPO}
- git config user.email "travis@travis.org"
- git config user.name "travis"
- git add .
- git commit --allow-empty -m "updated README.md"
- git push https://joesan:${GITHUB_API_KEY}@${GH_REPO} HEAD:master
因此,使用上面的脚本,我想做以下事情:
所以我的 deployment-version.txt 有以下内容:
plant-simulator-version=512
所以有了这个成功后的脚本,假设 TRAVIS_BUILD_VERSION 是 513,那么我期望
plant-simulator-version=513
作为我的新内容,我希望将此文件推送到回购中? 任何线索我怎么能做到这一点?
我设法通过编写一个只包含一行文本的新文件来做到这一点。 这是现在好的:因此我将其发布为解决方案:
after_success:
- MESSAGE=$(git log --format=%B -n 1 $TRAVIS_BUILD_NUMBER)
- git clone https://${GH_REPO}
- cd ${PLANT_SIMULATOR_DEPLOYMENT_REPO_NAME}
- rm deployment-version.txt # Remove the file
- touch deployment-version.txt # Add the file
- echo plant-simulator.version=${TRAVIS_BUILD_NUMBER} >> deployment-version.txt
- git config user.email "travis@travis.org"
- git config user.name ${USER} # this email and name can be set anything you like
- git add .
- git commit --allow-empty -m "release version for deployment tagged with version $TRAVIS_BUILD_NUMBER"
- git push https://${GITHUB_API_KEY}@${GH_REPO} HEAD:master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.