Can I use my existing git repo with openshift?

前端 未结 11 865
野的像风
野的像风 2020-11-28 17:36

Is it necessary to have git repo on openshift only? I already have bitbucket / github git repo and would prefer to push there only. Can I simply hook into it so that openshi

相关标签:
11条回答
  • 2020-11-28 17:40

    You should be able to pass in an existing Git repository into the asset pipeline via

    rhc create-app $APPNAME ruby-1.9 --from-code $GIT_LOCATION
    

    The remote Git repository then delivers the initial application for OpenShift.

    As a second possibility, you can skip the creation of the local OpenSHift Git repository via

    rhc create-app $APPNAME ruby-1.9 --no-git
    

    and then use the steps described above to merge the OpenShift remote Git repository into your local Git repository.

    0 讨论(0)
  • 2020-11-28 17:43

    If you're using github you can configure travis to made the deployment each time you made a change in your github repository

    http://docs.travis-ci.com/user/deployment/openshift/

    0 讨论(0)
  • 2020-11-28 17:44

    I know the question is 2-year old and the @adietisheim's answer has been accepted. I personally don't like to merge the openshift repo into my local clone because I don't want to mix the OpenShift repo into the master branch of my public repo.

    Assuming you have added the remote using git remote add openshift <openshift-git-repo-url>, here is what I would do:

    Create a new local branch openshift based on the master branch.

    git checkout -b openshift
    

    You could make some commits on the branch openshift such as your app deployment configurations. Then, push the current branch to the remote ref matching master in the OpenShift repository with the flag -f to overwrite everything in the remote master branch.

    git push openshift master -f
    

    Whenever I want to deploy my app to OpenShift, I would check out the local openshift branch and merge master branch with it, then force push to OpenShift, however -f may not be required for the next pushes:

    git checkout openshift
    git merge --no-ff master
    git push openshift master -f
    
    0 讨论(0)
  • 2020-11-28 17:46

    I have the impression that you're not used to use git enough yet. I'd advise you to get into git to fully understand how to push your code to openshift. Nevertheless let me try to explain you the steps involved: As you'd do with git in general, the approach to choose here is to clone your other git repo (ex. on bitbucket) to your local machine:

    git clone <bitbucket-repo-url>

    Your local clone has then your other repo (bitbucket etc.) as remote repo. Your remote repo is stored with the alias "origin" (the default alias used by git if you clone). You then add the openshift repo as remote to your clone. You do that while explicitly using an alias for the remote repo you add - I'm using "openshift" as alias here:

    git remote add openshift -f <openshift-git-repo-url>

    In order to then be able to push the code from your local git repo to openshift you first have to merge your openshift repo with your local bitbucket clone. You do that by issuing locally:

    git merge openshift/master -s recursive -X ours

    With this command you tell git to merge the master branch in the openshift git repo with your local git repo. You tell it to merge using the recursive merging strategy and to choose your ("ours") version when there are conflicts.

    Once the merge is executed you're ready to push your git repo to openshift. You do that by doing:

    git push openshift HEAD

    You tell git to push your local code to the HEAD branch on the remote repo called "openshift" (the alias we stored the openshift git repo at, some paragraphs further up).

    btw. I wrote a jboss tools blog which was demonstrating how to use the openshift-java-client some months ago: https://community.jboss.org/wiki/Enable-openshift-ciFullExampleUsingOpenshift-java-client . You'll spot the above steps in the last paragraph "We're almost there".

    0 讨论(0)
  • 2020-11-28 17:47

    There is a way to do what you want, i.e. skip Openshift's repo. What you need to do is set up a jenkins, and have it poll your own repository.

    There's a link here that explains how to set it up from scratch: http://blog.anthavio.net/2014/01/deploy-to-openshift-from-github.html

    0 讨论(0)
  • 2020-11-28 17:48

    If you are using java then there's is an alternative approach. But even in this approach you would still use the OpenShift git repository. The git repository provided by OpenShift is how you give OpenShift your code, your deployable(s):

    You can - instead of committing your code to the OpenShift git repo - simply give it your war-file. You clone the OpenShift git repo to your local machine. You then build a war from your application source and put this war into the deployments folder within your OpenShift git repo (clone). You then add, commit and push your local clone to OpenShift. Once the push executed successfully, the JBoss AS7 will pick your war and deploy it.

    0 讨论(0)
提交回复
热议问题