Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita26f217

Browse files
Merge branch 'master' into ftp-scp-examples
2 parents832189b +8ebfc8c commita26f217

File tree

8 files changed

+126
-88
lines changed

8 files changed

+126
-88
lines changed

‎_data/nav.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,10 @@
209209
sub-pages:
210210
-title:Deploy to VM
211211
url:"/packer-gcloud"
212-
-title:Deploy to a VM using ftp
212+
-title:Deploy to a VM using ftp
213213
url:"/transferring-php-ftp"
214+
-title:Deploy to Tomcat using SCP
215+
url:"/deploy-to-tomcat-via-scp"
214216
-title:Deploy with Helm
215217
url:"/helm"
216218
-title:Deploy with Terraform

‎_docs/learn-by-example/java/spring-mvc-jdbc-template.md‎

Lines changed: 0 additions & 87 deletions
This file was deleted.

‎_docs/whats-new/whats-new.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Recent Codefresh updates:
2323
- Installing the Codefresh runner behind proxy -[documentation]({{site.baseurl}}/docs/enterprise/codefresh-runner/#installing-behind-a-proxy)
2424
- Using Vault secrets in the Pipeline -[documentation]({{site.baseurl}}/docs/yaml-examples/examples/vault-secrets-in-the-pipeline/)
2525
- Deploy to a VM using FTP -[documentation]({{site.baseurl}}/docs/yaml-examples/examples/transferring-php-ftp)
26+
- Deploy to Tomcat using SCP -[documentation]({{site.baseurl}}/docs/yaml-examples/examples/deploy-to-tomcat-via-scp)
2627

2728
###February 2020
2829

‎_docs/yaml-examples/examples.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Codefresh can deploy to any platform such as VMs, FTP/SSH/S3 sites, app servers
8484

8585
-[Deploy to a VM with packer]({{site.baseurl}}/docs/yaml-examples/examples/packer-gcloud/)
8686
-[Deploy to a VM with FTP]({{site.baseurl}}/docs/yaml-examples/examples/transferring-php-ftp)
87+
-[Deploy to Tomcat using SCP]({{site.baseurl}}/docs/yaml-examples/examples/deploy-to-tomcat-via-scp)
8788
-[Deploy Demochat to a Kubernetes cluster]({{site.baseurl}}/docs/deploy-to-kubernetes/codefresh-kubernetes-integration-demochat-example/)
8889
-[Use kubectl as part of Freestyle step]({{site.baseurl}}/docs/yaml-examples/examples/use-kubectl-as-part-of-freestyle-step)
8990
-[Deploy with Helm]({{site.baseurl}}/docs/yaml-examples/examples/helm)
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
title:"Deploy to a VM via SCP"
3+
description:"Deploying your application to Tomcat using SCP"
4+
group:yaml-examples
5+
sub_group:examples
6+
toc:true
7+
---
8+
9+
##Prerequisites
10+
11+
- A[free Codefresh account](https://codefresh.io/docs/docs/getting-started/create-a-codefresh-account/)
12+
- A distribution of[Tomcat](https://tomcat.apache.org/download-90.cgi) setup on a remote server (running with port 8080 exposed)
13+
14+
##The Example Java Application
15+
16+
You can find the example project on[Github](https://github.com/codefresh-contrib/scp-war-app).
17+
18+
The example application is a simple Hello World Java application using the[Spark Java framework](http://sparkjava.com/):
19+
20+
{% include image.html
21+
lightbox="true"
22+
file="/images/examples/deployments/scp-hello-world.png"
23+
url="/images/examples/deployments/scp-hello-world.png"
24+
alt="Hello World!"
25+
caption="Hello World!"
26+
max-width="100%"
27+
%}
28+
29+
30+
```java
31+
@Override
32+
publicvoid init() {
33+
get("/hello", (req, res)->"Hello World");
34+
}
35+
```
36+
37+
##Create the Pipeline
38+
39+
Our pipeline will have three stages: clone, package, and transfer.
40+
41+
{% include image.html
42+
lightbox="true"
43+
file="/images/examples/deployments/scp-pipeline.png"
44+
url="/images/examples/deployments/scp-pipeline.png"
45+
alt="SCP pipeline"
46+
caption="Codefresh UI Pipeline View"
47+
max-width="100%"
48+
%}
49+
50+
You should be able to copy and paste this YAML in the in-line editor of the Codefresh UI. It will automatically clone the project for you.
51+
52+
Note that you need to change the environment variables under the`transfer` step to your respective values.
53+
54+
`codefresh.yml`
55+
```yaml
56+
# More examples of Codefresh YAML can be found at
57+
# https://codefresh.io/docs/docs/yaml-examples/examples/
58+
59+
version:"1.0"
60+
# Stages can help you organize your steps in stages
61+
stages:
62+
-"clone"
63+
-"package"
64+
-"transfer"
65+
66+
steps:
67+
clone:
68+
title:"Cloning repository..."
69+
type:"git-clone"
70+
stage:"clone"
71+
arguments:
72+
repo:"codefresh-contrib/scp-war-app"
73+
74+
package:
75+
title:"Packaging war..."
76+
type:"freestyle"
77+
stage:"package"
78+
arguments:
79+
image:"maven:3.5.2-jdk-8-alpine"
80+
working_directory:"${{clone}}"
81+
commands:
82+
-"mvn -Dmaven.repo.local=/codefresh/volume/m2_repository clean package"
83+
84+
transfer:
85+
title:"Transferring war to Tomcat..."
86+
type:"freestyle"
87+
stage:"transfer"
88+
arguments:
89+
image:"ictu/sshpass:latest"
90+
working_directory:"${{package}}/target"
91+
environment:
92+
-USER=<USER>
93+
-HOST=<HOST.IP.ADDRESS>
94+
-PASSWORD=<PASSWORD>
95+
-TOMCAT_DIR=<path/to/tomcat/webapps>
96+
commands:
97+
-"echo | ssh-keygen -P '' -t rsa"
98+
-"sshpass -p $PASSWORD ssh-copy-id -i /root/.ssh/id_rsa.pub -o StrictHostKeyChecking=no $USER@$HOST"
99+
-"scp sparkjava-hello-world-1.0.war $USER@$HOST:$TOMCAT_DIR"
100+
```
101+
102+
The above pipeline does the following:
103+
104+
1. A [git-clone]({{$site.baseurl}}/docs/codefresh-yaml/steps/git-clone/) step that clones the main repository
105+
2. A [freestyle step]($$site.baseurl}}/docs/codefresh-yaml/steps/freestyle/) that installs the dependencies via Maven and packages our war file
106+
3. A freestyle step that transfers our application via scp to a Tomcat server. Note that you will need to change the listed environment variables accordingly, either through the YAML itself, or through your pipeline settings:
107+
108+
{% include image.html
109+
lightbox="true"
110+
file="/images/examples/deployments/scp-variables.png"
111+
url="/images/examples/deployments/scp-variables.png"
112+
alt="Pipeline variables"
113+
caption="Pipeline variables"
114+
max-width="100%"
115+
%}
116+
117+
## What to Read Next
118+
119+
- [Git-clone Step]({{site.baseurl}}/docs/codefresh-yaml/steps/git-clone/)
120+
- [Freestyle Step]({{site.baseurl}}/docs/codefresh-yaml/steps/freestyle/)
121+
- [Deploying to a VM using FTP]({{site.baseurl}}/docs/yaml-examples/examples/transferring-php-ftp/)
9.58 KB
Loading
23.6 KB
Loading
21.3 KB
Loading

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp