strider icon indicating copy to clipboard operation
strider copied to clipboard

Deploy only when create a new release/tag

Open fernandoneto opened this issue 10 years ago • 30 comments

i would like to know if is possible configure strider to deploy using github tags instead of using directly branch's.

fernandoneto avatar Feb 20 '15 12:02 fernandoneto

@fernandoneto sounds like a nice idea, although not currently supported. You might be able to write a bash script and use it in the custom scripts plugin..

knownasilya avatar Feb 20 '15 14:02 knownasilya

@knownasilya thank you for your fast answer. about the bash script idea i cant get your train of thought. can you please be more verbose? :)

fernandoneto avatar Feb 20 '15 14:02 fernandoneto

You could use something like this in a bash if statement in the strider-custom's (installed by default, enable it in the branches plugins) deploy section.

knownasilya avatar Feb 20 '15 14:02 knownasilya

@knownasilya thank you for your help :+1:

fernandoneto avatar Feb 20 '15 15:02 fernandoneto

@knownasilya in fact i think i express myself wrong. what i really want is after create a new tag based in a branch, strider is able to deploy it.

so my question is : If i create a tag in Github, strider will be notify and run based in that tag?

let me give you an example:

You and your team work in a branch for some time, every time you push commits strider run tests. So you want to send the code to productin servers. You create a tag based in that branch, and strider will deploy the code. maybe this can be possible using webwooks i think ???

hope you understand my idea :)

fernandoneto avatar Feb 20 '15 18:02 fernandoneto

Ah, so you're wondering if pushing a tag will kick off a job in strider? Not sure..

But using that SO answer you can increment a version somewhere and tag it, and just check if that commit has a tag. It's a workaround, but it's better then nothing.

knownasilya avatar Feb 20 '15 18:02 knownasilya

Yep thats it. maybe a plugin that give this options would be very usefull don't you think?

fernandoneto avatar Feb 20 '15 18:02 fernandoneto

Sounds like a feature for strider-github, strider-bitbucket and strider-gitlab

knownasilya avatar Feb 20 '15 18:02 knownasilya

https://developer.github.com/webhooks/#events https://github.com/Strider-CD/strider-github/blob/master/lib/api.js#L42 https://github.com/Strider-CD/strider-github/blob/master/lib/webhooks.js#L227

Add the create and release events to handle tags and releases.

The only issue is how do you decide which branch to trigger? Maybe postfix the tags with the branch name (also have option to configure it)?

  • master: v1.0.0
  • develop: v1.0.0-develop
  • feature-a: v1.0.0-feature-a

Feel free to play around with some ideas, and submit a PR to try it out.

knownasilya avatar Feb 20 '15 18:02 knownasilya

I can confirm new tags kick off a job in Strider, at least with Github and Bitbucket. I'm not sure if it is at the provider's discretion whether or not to push that info in a webhook.

I believe only Github starts jobs for Pull Requests, but I don't think so for Bitbucket

bitwit avatar Feb 20 '15 20:02 bitwit

@bitwit just tags by themselves, i.e. git push --tags?

knownasilya avatar Feb 20 '15 20:02 knownasilya

Yep, I just tested it a couple times even. They don't come back with anything in the 'branch' column though. Not sure about what the Strider metadata contains either.

screen shot 2015-02-20 at 3 54 16 pm

bitwit avatar Feb 20 '15 20:02 bitwit

Interesting, I think it's registered as a commit, because that's the default.

So yeah, builds no longer make sense to be focused on a branch so tightly.

knownasilya avatar Feb 20 '15 20:02 knownasilya

@knownasilya i already have strider start from release new tags. my proble now is the same as @bitwit . i can get any information in branch column. captura de ecra de 2015-03-12 15 23 52

Could you tell me the file where i found that confguration?

fernandoneto avatar Mar 12 '15 15:03 fernandoneto

@fernandoneto tags are not placed on branches, so you can't have branch info. This is why fundamentally strider needs to be reworked to have builds not heavily tied to branches.

knownasilya avatar Mar 12 '15 15:03 knownasilya

Although, github releases might be tied to branches.

knownasilya avatar Mar 12 '15 15:03 knownasilya

Hey @knownasilya !

@fernandoneto is my co-worker/mate!! :) I asked him to place and follow up this discussion so we can fire releases to our production servers directly from GitHub releases instead of branch updates. Thanks for bringing up discussion about this so far!

github releases might be tied to branches

GitHub releases are created on top of git tags, which means that you couldn't have a GitHub release without having a git tag.

Since Strider is catching up git tags as branches, could the configuration be as simple as creating settings for refs/tags/* ?

captura de ecra 2015-03-12 as 23 13 53

cusspvz avatar Mar 12 '15 23:03 cusspvz

Note: I didn't tested it, but i think it might work.

cusspvz avatar Mar 12 '15 23:03 cusspvz

So that most likely will work, but the problem is that strider expects a certain output to keep the reference of your build, and this output happens to be the branch information. For tags to be supported properly, strider needs some changes. Currently it will probably hit the * "branch" when you use a tag.

knownasilya avatar Mar 13 '15 11:03 knownasilya

but the problem is that strider expects a certain output to keep the reference of your build, and this output happens to be the branch information.

What kind of branch information?

Just tested a git checkout directly from refs/tags/... and git sees it as detached HEAD. If Strider is okay with that, we just need to access to some kind of build history to avoid Strider to build already built tags (in case we mess up with something).

EDIT: PoC for my last statement: captura de ecra 2015-03-13 as 12 56 36

cusspvz avatar Mar 13 '15 13:03 cusspvz

Basically Strider needs something to associate the tag to a build, which is what is done with branches, it's associated by the branch name. Since tags are different every time, we'd need a tag pattern, like a regex or something.

Something like {semver}-production, where v1.2.3-production would trigger that build.

knownasilya avatar Mar 13 '15 13:03 knownasilya

Well, I spent a couple of minutes trying to make a semver-compatible regexp (already with version descriptors checking) in case you need it.

^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}(?:-[a-z0-9\-]*)?$ some acceptance testing

For my understanding perspective, and correct me if I'm wrong, you're saying that current working Strider version can do the job if we place some pattern to detect a sort of tags? Like refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}-production?

cusspvz avatar Mar 13 '15 15:03 cusspvz

It will need some tweaking to match up the tag with the build (the regexp, and look at the right data), since the response from github is different for tags.

knownasilya avatar Mar 13 '15 15:03 knownasilya

Could you please assign me for this? This weekend i will review entire Strider and strider-github code and PR this feature.

cusspvz avatar Mar 13 '15 21:03 cusspvz

@cusspvz feel free to submit a PR. We can iterate till it looks good.

You might be looking at strider-git instead, since it's at the tag level.

knownasilya avatar Mar 14 '15 02:03 knownasilya

@cusspvz have you had any success with this?

knownasilya avatar Mar 24 '15 17:03 knownasilya

This is currently at my urgent TODOs since we have it as a dependency. Maybe tomorrow I will dig up on this.

cusspvz avatar Mar 24 '15 19:03 cusspvz

I've read entire strider-github repo already, since there are a couple of ways to apply this, i will get into this afternoon because I need to discover differences between payloads first.

cusspvz avatar Apr 02 '15 16:04 cusspvz

Any news about this problem?

anddimario avatar Nov 24 '16 15:11 anddimario

I'll have a look at it this weekend.

knownasilya avatar Nov 24 '16 18:11 knownasilya