clever-tools
clever-tools copied to clipboard
`Deploy` command with `--force` option doesn't work properly
Actually, if you want to deploy the same commit twice, even with -f
option, the command will return an error [ERROR] The clever-cloud application is up-to-date. Try this command to restart the application: clever restart
.
Without force
option, restart
sounds like fine.
However deploy
with --force
option should still be OK.
Current use case is : deploying from Gitlab-CI, triggering manual action that will rebuild the website and run every CC HOOKS.
Interesting...
So right now here's the output:
$ clever deploy
[ERROR] The clever-cloud application is up-to-date. Try this command to restart the application:
clever restart
exit status: 1
$ clever deploy --force
[ERROR] The clever-cloud application is up-to-date. Try this command to restart the application:
clever restart
exit status: 1
It seems like you don't want to change the situation for clever deploy
but you expect a different behaviour from clever deploy --force
. I see two possibilities:
- A bit like what a
git push
would do: we just log that everything is up to date without any errors. - Forcing the deploy would mean you want to automatically trigger a restart if the remote is already up to date.
This seems simple but I think it requires some thinking...
It seems like you don't want to change the situation for clever deploy
true
About the possibilities, it's more the 2
that I expect.
As a side note, --force
option before 1.0.0
has the same behavior of git push --force
.
Looks like it's not the case anymore.
IIRC, we used the same behavior that git has . clever deploy --force
== git push --force
. If there is nothing to push, no deployment is started and if you want to restart, you have to use the clever redeploy
command.
Here's what you have with version 0.10.1:
$ clever-old deploy
Pushing source code to Clever Cloud.
[ERROR] The clever-cloud application is up-to-date. Try `clever restart` to restart the application
exit status: 0
$ clever-old deploy -f
Pushing source code to Clever Cloud.
[ERROR] The clever-cloud application is up-to-date. Try `clever restart` to restart the application
exit status: 0
We "just" fixed the fact that logging an error should also return an exit status code 1 and log to stderr.
ok, looks like my brain is a liar (and my CI to :smile: )
An other option to not change the behavior describe by @BlackYoup is to add a not option.
Something like --restart
that can run a restart if git commit are the same ?
Hi,
Any update on this issue ? It would be really useful to deploy twice on the same commit.
Hi @jeremybastin1207, thanks for you message.
This project clearly lacked some love in the past years and we're sorry about that. We recently put the project back on tracks and we're putting more time and effort on it.
About this issue, this is clearly a "simple to implement" and a "not that complex to design".
We'll be discussing the design of this issue next tuesday with @aurrelhebert and see what we can quickly move forward with :wink:
Observations:
-
git push
with same remote commit returnsEverything up-to-date
and exit 0 -
git push --force
with same remote commit returnsEverything up-to-date
and exit 0 -
clever restart
has a--without-cache
option for the restart
We discussed this issue with @aurrelhebert and here's our report.
Context
Users want to use the clever-tools in their CI (GitLab, GitHub, Jenkins...). The classic scenario is:
- Someone does a
git push
(or merge) which triggers the CI tool - The CI tool runs the job (checks, tests, validations...)
- If everything passes, the CI tool wants to deploy the commit to Clever Cloud
A clever deploy
should be enough but there are some caveats:
- if the git history was rewritten,
clever deploy
will fail and require--force
- if the commit to be deployed is the same as the remote commit,
clever deploy
andclever deploy --force
will fail and inform the user to do aclever restart
.
There's no way to detect a clever deploy
failed because the remote commit was the same.
Therefore, users cannot safely and automatically trigger et clever restart
in this very situation (remote commit is the same).
The need
Users need a "please deploy this commit even if it's already the one on the remote".
- Could be combined with "please deploy this commit even if the git history was rewritter"
- this is the
--force
option ofclever deploy
- this is the
- Could be combined with "when deploying, don't use the build cache et force the build"
- this is the
--without-cache
ofclever restart
- this is the
The proposition
Here are some examples to explain the current behaviour and our propositions.
Current behaviour
clever deploy
- fails if remote commit is the same
- fails if git history was rewritten
clever deploy --force
- fails if remote commit is the same
- works, even if git history was rewritten
New --same-commit-policy
param
The name is a bit long but explicit and self-explanatory.
clever deploy --same-commit-policy=restart
- works, even if remote commit is the same
- the restart (or start if app was stopped) will try to use the build cache
- fails if git history was rewritten
clever deploy --same-commit-policy=rebuild
- works, even if remote commit is the same
- the restart (or start if app was stopped) will NOT use the build cache
- fails if git history was rewritten
clever deploy --same-commit-policy=ignore
- if remote commit is the same
- no deployment is triggered
- but the command does not error
- fails if git history was rewritten
clever deploy --same-commit-policy=error
clever deploy
NOTE: error
is the default value, same as not using the param explicitly
Combine --force
and --same-commit-policy
Depending on what you need, you could combine --force
and --same-commit-policy
.
clever deploy --force --same-commit-policy=restart
- works, even if remote commit is the same
- the restart (or start if app was stopped) will try to use the build cache
- works, even if git history was rewritten
clever deploy --force --same-commit-policy=rebuild
- works, even if remote commit is the same
- the restart (or start if app was stopped) will NOT use the build cache
- works, even if git history was rewritten
clever deploy --force --same-commit-policy=ignore
- if remote commit is the same
- no deployment is triggered
- but the command does not error
- works, even if git history was rewritten
Request for comments
Please tell us what you think of this. It will be combined with other works on the clever deploy
command with --timeout
, --watch=false
and discussions about deploying a specific commit or tag.
poke @jeremybastin1207 @jygastaud
Hi @hsablonniere, Thanks for this detailed report. The command "clever deploy --force --same-commit-policy=rebuild" fullfills my need to re-deploy on the same commit with a rewritten git history.
@jeremybastin1207 Thank you for your feedbacks. Sorry for the holiday delay :p