Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Deploying with an empty repositoryUrl (i.e. without pulling from git) doesn't seem to work #207

Closed
atleta opened this issue Jul 26, 2018 · 13 comments · Fixed by #226
Closed

Comments

@atleta
Copy link

atleta commented Jul 26, 2018

Hi,

The documentation says that by leaving repositoryUrl empty (though that's a bit ambiguous) shipit can be used to deploy without fetching from git (possibly using the local directory?): "If empty Shipit will try to deploy without pulling the changes."

Now when I try to do that, it seems to ignore the above and tries to do the normal flow, it seems, which fail because of the missing repo url:

Running 'deploy:init' task...
Finished 'deploy:init' after 647 μs

Running 'deploy:fetch' task...
Create workspace...
Workspace created: "/tmp/tmp-100255o9Se5wCMUtf"
Initialize local repository in "/tmp/tmp-100255o9Se5wCMUtf"
Running "git init" on local.
@ Initialized empty Git repository in /tmp/tmp-100255o9Se5wCMUtf/.git/
Repository initialized.
List local remotes.
Running "git remote" on local.
Update remote "" to local repository "/tmp/tmp-100255o9Se5wCMUtf"
Running "git remote add shipit " on local.
@ usage: git remote add [<options>] <name> <url>
@
@     -f, --fetch           fetch the remote branches
@     --tags                import all tags and associated objects when fetching
@                           or do not fetch any tag at all (--no-tags)
@     -t, --track <branch>  branch(es) to track
@     -m, --master <branch>
@                           master branch
@     --mirror[=<push|fetch>]
@                           set up remote as a mirror to push to or fetch from
@
'deploy:fetch' errored after 27 ms
Error: Command failed: git remote add shipit
usage: git remote add [<options>] <name> <url>

    -f, --fetch           fetch the remote branches
    --tags                import all tags and associated objects when fetching
                          or do not fetch any tag at all (--no-tags)
    -t, --track <branch>  branch(es) to track
    -m, --master <branch>
                          master branch
    --mirror[=<push|fetch>]
                          set up remote as a mirror to push to or fetch from


    at ChildProcess.exithandler (child_process.js:270:12)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:921:16)
    at Socket.stream.socket.on (internal/child_process.js:348:11)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at Pipe._handle.close [as _onclose] (net.js:549:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@sandervankasteel
Copy link

sandervankasteel commented Nov 18, 2018

I have found a workaround for this (if this is still relevant for you @atleta ).. Install shipit-utils add the following snippet to your shipitfile.js

  var utils = require('shipit-utils');

  // Deploy from working directory without repository fetch
  utils.registerTask(shipit, 'deploy:fetch', function() {

    // Set the workspace variable which is originally set in overridden deploy:fetch
    // This variable is needed in deploy:update and some other tasks
    shipit.workspace = shipit.config.workspace;
  
    shipit.emit('fetched');
  });

And of course set your repositoryUrl to an empty string :)

@SleepWalker
Copy link
Contributor

faced the same issue. Despite in the docs states:

If empty Shipit will try to deploy without pulling the changes.

It still tries to fetch undefined or everything you will set in repositoryUrl. In the source code I can't see any logic, that should handle the flow without repository:

https://github.com/shipitjs/shipit/blob/master/packages/shipit-deploy/src/tasks/deploy/fetch.js

@sandervankasteel thank you for the working solution!

@gregberge
Copy link
Member

Don’t hesitate to submit a PR to fix it.

@SleepWalker
Copy link
Contributor

@neoziro it's ready to merge. I have two more PR's that I would like to submit

@lili21
Copy link

lili21 commented Jul 9, 2019

doesn't work to me.

image

@SleepWalker
Copy link
Contributor

@lili21 yep, the problem is that fetch task still requires workspace path and must not be root. If you'll setup something different, the deploy will fail on update command, when it will look for commit hash to save it to REVISION file.

To fix this we, probably, need another deploy flow with read-only workspace

as a workaround, you can override fetch task:

  // Deploy from working directory without repository fetch
  shipit.task('deploy:fetch', () => {
    // Set the workspace variable which is originally
    // set in overridden deploy:fetch
    // This variable is needed in deploy:update and some other tasks
    shipit.workspace = shipit.config.workspace;

    shipit.emit('fetched');
  });

If it won't take too much time, I'll try to post a new PR

@SleepWalker
Copy link
Contributor

@lili21 the just published v5.0.0 should work out of the box without any hacks. See: https://github.com/shipitjs/shipit/tree/master/packages/shipit-deploy#workspace

@lili21
Copy link

lili21 commented Jul 16, 2019

Still doesn't work.

// shipitfile.js
module.exports = shipit => {
  require('shipit-deploy')(shipit)

  shipit.initConfig({
    default: {
      workspace: '/tmp/test'
      keepWorkspace: true,
      deployTo: '/var/test'
    },
    dev: {
      servers: 'xxxx'
    }
  })
}

same error.

@SleepWalker
Copy link
Contributor

According to this rows that looks not really possible, that your workspace will be deleted.

same error.

an error with rev-parse is not really an issue with workspace or repositoryUrl. During release shipit will get current commit id from git, that must be located in workspace directory ('/tmp/test' in your case). keepWorkspace is needed to ensure, that shipit won't remove repo (workspace) directory after deploy finished (see the link above)

Do you want to deploy something, that does not belong to any repository? If so, then you need to create a separate issue.

@lili21
Copy link

lili21 commented Jul 18, 2019

I just want to deploy a docker container application. I don't see the need to clone a repository. I just need to pull the image and run it.

@aurelijusrozenas
Copy link

It's still not possible to deploy without repositoryUrl because it fails to create revision file.

Setting current revision and creating revision file.
Running "git rev-parse master" on local.
@ fatal: not a git repository (or any of the parent directories): .git
Maybe this ticket should be reopened or renamed so that it would no confuse people. I found this and thought that now shipit can deploy without git repository.

@SleepWalker
Copy link
Contributor

SleepWalker commented Sep 2, 2019 via email

@EduardsE
Copy link

EduardsE commented Nov 23, 2019

How would one deal with a monorepo and microservices where all your services are in one git repo, but you would like to deploy them separately?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

7 participants