1
00:00:04,800 --> 00:00:12,790
With this new future of dynamically using and creating environments, we have created a problem as well.

2
00:00:13,230 --> 00:00:20,040
And once the branch has been merged, there's actually no need to keep that environment running.

3
00:00:21,030 --> 00:00:24,030
And by default, it will still continue to run.

4
00:00:24,750 --> 00:00:26,870
And we have the possibility of stopping it.

5
00:00:27,750 --> 00:00:34,260
But this will not actually do anything because we haven't really instructed Gottleib Lab on how to stop

6
00:00:34,260 --> 00:00:35,030
the environment.

7
00:00:40,040 --> 00:00:42,510
And this is exactly what we're going to do in this lecture.

8
00:00:42,680 --> 00:00:48,490
We are going to look into how we can stop the environment as soon as we don't need them anymore.

9
00:00:51,730 --> 00:00:57,100
From a technical point of view, the problem that we have is that we have instructed Surge to create

10
00:00:57,100 --> 00:01:05,260
this domain and we have deployed the files there and we need a way to tell Sergej, hey, we don't need

11
00:01:05,260 --> 00:01:05,890
this anymore.

12
00:01:09,250 --> 00:01:15,370
And luckily, there's a HelpAge on search explaining us how we can destroy your projects or how we can

13
00:01:15,370 --> 00:01:18,850
turn down a project in the command for that is quite simple.

14
00:01:18,850 --> 00:01:24,070
We simply specify search teardown down and then we specify where it is.

15
00:01:24,520 --> 00:01:26,470
But what is the name of the address?

16
00:01:27,730 --> 00:01:33,070
So let's go back to our configuration and create a job that will turn down a published project.

17
00:01:36,070 --> 00:01:38,240
So let's start with the following configuration.

18
00:01:38,920 --> 00:01:44,920
Now, the name of the job is Stop Review, and it's still part of the stage diploid review.

19
00:01:46,220 --> 00:01:55,490
We want to run this stop review job when the branch has already been merged and possibly deleted as

20
00:01:55,490 --> 00:02:03,260
we have configured, so for that reason, we need to specify here a good strategy and this is needed

21
00:02:03,260 --> 00:02:09,680
so that this job doesn't try to clone this specific branch, which may no longer exist.

22
00:02:10,039 --> 00:02:14,780
And the way you specify this is by defining this strategy variable.

23
00:02:14,930 --> 00:02:16,400
And we are going to set it to none.

24
00:02:16,940 --> 00:02:23,420
As you see, it is variable is defined only inside this job and only has an effect for this job.

25
00:02:24,890 --> 00:02:28,490
Good strategy is a variable that kid Lapkin understand.

26
00:02:28,490 --> 00:02:32,570
And if we set it tanon, it will not clent this repository.

27
00:02:36,090 --> 00:02:39,300
Now, from the scripting point of view, there are a couple of things we need to do.

28
00:02:39,930 --> 00:02:42,150
You still need to globally install search.

29
00:02:42,360 --> 00:02:43,650
So I'm going to replace this.

30
00:02:46,490 --> 00:02:55,490
And as you have seen, we need to use surge here down and then we need to specify the domain name.

31
00:03:05,690 --> 00:03:12,440
Additionally, we need to establish a link between diploid review and stop review, and we do it by

32
00:03:12,440 --> 00:03:17,090
additional configuring the environment and we are going to sit here on stop.

33
00:03:18,890 --> 00:03:23,470
This will be stop review because this is the name of the job.

34
00:03:31,080 --> 00:03:35,460
OK, so let's go ahead and create a new branch and see how this performs.

35
00:03:39,580 --> 00:03:42,100
Now, the pipeline for much request has executed.

36
00:03:42,320 --> 00:03:43,260
Let's take a look at it.

37
00:03:47,850 --> 00:03:50,040
You notice that not much has changed.

38
00:03:50,480 --> 00:03:58,910
We still have the three stages and this job that was supposed to stop the review system doesn't really

39
00:03:58,910 --> 00:04:05,180
show up in this pipeline, not first of all, let's open the website and see that it works.

40
00:04:06,080 --> 00:04:12,670
Again, this is another address that has been dynamically generated, but everything works just fine.

41
00:04:13,610 --> 00:04:20,149
Now, we could go ahead and manually stop the environment here, but this will be an additional manual

42
00:04:20,149 --> 00:04:22,040
step that we do not want to do.

43
00:04:22,760 --> 00:04:28,390
We want to let Getler do this for us when we march and delete this brunch.

44
00:04:28,400 --> 00:04:30,690
So let's click on March and see what happens.

45
00:04:38,920 --> 00:04:46,090
Initially, not much has happened, but let's now take a moment to inspect the pipeline for the monster

46
00:04:46,090 --> 00:04:46,570
branch.

47
00:04:49,230 --> 00:04:55,900
And you will see here that it now has the build and the test stages that we already know, and it has

48
00:04:55,900 --> 00:04:57,900
the Deepthi review stage as well.

49
00:04:59,020 --> 00:05:03,880
And actually this is happening because we have forgotten to do something.

50
00:05:04,240 --> 00:05:07,000
I've forgotten to exclude this from Uster.

51
00:05:07,000 --> 00:05:12,610
And yeah, diploid review is part of the pipeline and it has a job.

52
00:05:12,610 --> 00:05:14,860
And this is why it has decided to have this job here.

53
00:05:15,250 --> 00:05:16,770
This is definitely not OK.

54
00:05:17,590 --> 00:05:22,630
So I'm going to quickly go ahead and fix this and we're going to take a second look at this.

55
00:05:25,030 --> 00:05:29,680
So what we actually want for the stop preview as well is to get this only flag.

56
00:05:31,610 --> 00:05:33,950
So that it only works for much requests.

57
00:05:35,690 --> 00:05:40,430
This is what has been missing, and for that reason, he has showed up on the massive pipeline.

58
00:05:43,400 --> 00:05:49,490
A pipeline for the project is not successful, and we click this link, we can easily inspect the app

59
00:05:49,490 --> 00:05:50,540
that we have deployed.

60
00:05:54,410 --> 00:05:57,460
Now, let's go ahead and watch this and see what happens.

61
00:06:02,460 --> 00:06:09,570
Now, you will see that as soon as we have marched to branch, this has started, the pipeline for this

62
00:06:09,570 --> 00:06:10,770
branch has started again.

63
00:06:14,660 --> 00:06:20,180
And if you take a closer look at it, you will see that diplo review has been deployed and this is working

64
00:06:20,750 --> 00:06:28,340
and now Stop Review has started doing its job and this has been automatically triggered by Gottleib.

65
00:06:28,700 --> 00:06:31,940
As I have said, you can manually trigger this as well.

66
00:06:32,300 --> 00:06:36,790
But we were definitely interested in letting get laboratory goodies for us.

67
00:06:39,750 --> 00:06:43,800
Now we can see that star preview was successful, so.

68
00:06:45,690 --> 00:06:52,020
If we go now back to the website and hit the refresh, we should no longer see diSEMBOWELMENT.

69
00:06:53,900 --> 00:06:56,690
And this is how it looks like project not found.

70
00:06:57,260 --> 00:06:58,820
So basically.

71
00:07:00,490 --> 00:07:06,850
Everything has worked as we have expected, so let's go back to the project configuration and review

72
00:07:06,850 --> 00:07:07,840
again what we have done.

73
00:07:09,860 --> 00:07:18,800
Now, we have added another job called Stop Review, and the way we have linked this is that by diploid

74
00:07:18,800 --> 00:07:25,940
review, when specifically the environment we have added on stop and we are referencing stop review

75
00:07:27,470 --> 00:07:34,600
now, stop review is triggered manually and it will not run automatically when the pipeline runs.

76
00:07:34,610 --> 00:07:37,130
And this is why when manual is needed.

77
00:07:37,640 --> 00:07:41,780
Now, manual doesn't mean that Getler cannot trigger it.

78
00:07:42,620 --> 00:07:48,650
So for that reason, this is like a semi manual thing where when we are deleting the branch, when we

79
00:07:48,650 --> 00:07:56,060
are merging, our request actually get can point a finger at a stop button and will trigger this, but

80
00:07:56,060 --> 00:07:57,530
otherwise this will not get triggered.

81
00:07:58,920 --> 00:08:01,160
Additionally, there are things that we need to have here.

82
00:08:02,020 --> 00:08:09,580
So we need to have this environment and the name of the environment must match the name of the environment

83
00:08:09,580 --> 00:08:10,630
we are trying to stop.

84
00:08:11,770 --> 00:08:14,800
So if there's any mismatch there, this will not work.

85
00:08:15,580 --> 00:08:17,830
And again, here, the action needs to be stopped.

86
00:08:18,790 --> 00:08:25,380
And apart from this, we have added this strategy so that we do not take out any files.

87
00:08:25,900 --> 00:08:30,770
And this is simply the script that is actually tearing down the environment.

88
00:08:31,330 --> 00:08:38,110
So there are a few rules that we need to follow in order to make it work as Kit expects it to work.

89
00:08:38,470 --> 00:08:41,289
So this is why all this extra configuration around it.

90
00:08:41,409 --> 00:08:44,580
But the core of this is simply this command.

91
00:08:44,740 --> 00:08:46,750
This is how we turn down the environment.

92
00:08:46,960 --> 00:08:50,020
The rest of it is how Getler instructs us to do it.

93
00:08:50,830 --> 00:08:53,500
Nevertheless, we have achieved something very, very cool.

94
00:08:53,860 --> 00:08:59,860
Now we can spin up environments and when we don't need them anymore, we can turn them down and they

95
00:08:59,860 --> 00:09:00,590
will disappear.

96
00:09:00,730 --> 00:09:03,670
And yeah, everything is very eco friendly.

