andres-montanez/Magallanes

Unclear branch change error

tislars opened this issue · 3 comments

I use Magallanes in a Jenkins solution. When I run vendor/bin/mage deploy production manually in my own environment, it succeeds. However, an error occurs when it is trying to deploy my project to production when the deploy command is run in Jenkins. In the post-deploy stage it is not able to change branch. Why is it trying to change branch anyway?

+ vendor/bin/mage deploy production
Starting Magallanes

    Environment: production
    Release ID: 20170607064922
    Strategy: Releases
    Branch: master

    Starting Pre Deploy tasks:
        Running [Git] Change Branch (master) ... OK
        Running [Git] Update ... OK
        Running [Composer] Install ... OK
        Running [Composer] Dump Autoload ... OK
        Running [Deploy] Preparing Tar file ... OK
    Finished 5/5 tasks for Pre Deploy.

    Starting On Deploy tasks on host atlas:
        Running [Release] Preparing Release ... OK
        Running [Deploy] Copying files with Tar ... OK
    Finished 2/2 tasks for On Deploy.

    Starting On Release tasks on host atlas:
        Running [Release] Creating Symlink ... OK
    Finished 1/1 tasks for On Release.

    Starting Post Release tasks on host atlas:
        Running [Release] Cleaning up old Releases ... OK
    Finished 1/1 tasks for Post Release.

    Starting Post Deploy tasks:
        Running [Deploy] Cleanup Tar file ... OK
        Running [Git] Change Branch ((detached from ba24ba1)) ... FAIL
    Finished 1/2 tasks for Post Deploy.


Stage "Post Deploy" did not finished successfully, halting command.

Finished Magallanes
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Here is my Magallanes configuration:

magephp:
    environments:
        production:
            user: root
            branch: master
            from: ./
            host_path: ~/vhosts/foo.bar/httpdocs
            releases: 2
            exclude:
                - web/content
            hosts:
                - webserver
            pre-deploy:
                - git/update
                - composer/install
                - composer/dump-autoload
            on-deploy:
            on-release:
            post-release:
            post-deploy:

Currently have same error, any idea's yet?

"This task is automatically added by Magallanes at the beginning of the Pre Deploy stage if you have the option branch defined. It will look if the current checked out branch and skip if it's the same as branch or change to it with git checkout branch. If the switch was made, the task will remember the original branch and reverse it at the Post Deploy stage. This is handled automatically by Magallanes."

Just remove the branch option.

Hi @tislars can you post the log?
But looks like you executed the deployment (you or jenkins) in a branch different than master, that's why the checkout was executed. If you are already on the branch you need to deploy, do not use the branch option as suggested bu @svparijs

Regards.