从Travis CI推送到master分支 [英] Push into master branch from Travis CI

查看:75
本文介绍了从Travis CI推送到master分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从詹金斯(Jenkins)转到特拉维斯CI(Travis CI).

I am switching from Jenkins to Travis CI.

在Jenkins中,我不必编写脚本即可将Java/android库推送到Git master分支.

In Jenkins, I did not have to write a script to push my Java/android library to Git master branch.

通过Travis,我所有的研究都表明我需要编写一个自定义的bash脚本才能在after_success中执行.

With Travis, all my research shows that I need to write a custom bash script to execute in after_success.

这是我的deploy.sh:

#!/bin/bash
rev=$(git rev-parse --short HEAD)
git config user.name "uname"
git config user.password "password"
git add .
git commit -m "travis commit at ${rev}"
git push origin master

和我的.travis.yml:

branches:
  only:
    - development

language: android
sudo: false

android:
  components:
    - build-tools-22.0.1
    - android-22

script:
  - cd appdir
  - ./gradlew test


after_success:
  - cd ..
  - ./deploy.sh

before_cache:
  - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/

script部分下,我从根目录cd到我的appdir,然后从那里运行测试(成功),然后在after_success部分中,我cd回到根目录下,我的deploy.sh位于并调用它.

Under the script section, I cd from root dir to my appdir and run tests from there (successfully) then in the after_success section, I cd back into root where my deploy.sh is located and call it.

我的Travis CI控制台显示一切都成功,但是我的master分支没有看到任何更改.

My Travis CI console shows everything is successful but I don't see any changes in my master branch.

我做错什么了吗?

谢谢.

推荐答案

我的经验是,Git不会显示您的构建正在使用的分支,并且您想推送具有附加提交的当前HEAD.

My experience is that Git doesn't appear know the branch your build is using and you want to push the current HEAD that has the additional commit.

在Travis CI中,当Git推送相同的master分支时,您可能会收到一条日志消息,仅显示所有最新信息".

In Travis CI you may have a log message just showing 'Everything up-to-date' as Git is pushing the same master branch.

您可以更改脚本以添加HEAD.

You could change your script to add HEAD.

#!/bin/bash
rev=$(git rev-parse --short HEAD)
git config user.name "uname"
git config user.password "password"
git add .
git commit -m "committed at ${rev}"
git push origin HEAD:master

这是一个类似的答案,它解释了:- git-pushing-到github-origin-master-does-nothing .

This is a similar answer that explains :- git-pushing-to-github-origin-master-does-nothing.

这篇关于从Travis CI推送到master分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆