Start Here » History » Version 6
Luke Murphey, 03/25/2017 11:28 PM
1 | 1 | Luke Murphey | h1. Start Here |
---|---|---|---|
2 | 2 | Luke Murphey | |
3 | 2 | Luke Murphey | h2. Why should I use this build script? |
4 | 2 | Luke Murphey | |
5 | 2 | Luke Murphey | This build script will make developing and deploying Splunk apps easier by: |
6 | 2 | Luke Murphey | |
7 | 2 | Luke Murphey | * *Creating installable Splunk packages* (from a directory with the source code) |
8 | 2 | Luke Murphey | * *Providing a simple method to deploy the changes to an app to a Splunk instance in seconds*; this is useful during development since it will tell the Splunk instance to refresh so that your new content can be tested in real-time |
9 | 2 | Luke Murphey | * *Providing mechanisms for deploying Splunk apps to a production box*. This allows you to install the app remotely and restart the Splunk install accordingly using a Continuous Deployment system. |
10 | 2 | Luke Murphey | * *Improving the performance of apps* with Javascript views by minifying the CSS and JS files |
11 | 2 | Luke Murphey | |
12 | 5 | Luke Murphey | Here are some examples: |
13 | 5 | Luke Murphey | |
14 | 5 | Luke Murphey | <pre> |
15 | 5 | Luke Murphey | ant package |
16 | 5 | Luke Murphey | </pre> |
17 | 5 | Luke Murphey | |
18 | 5 | Luke Murphey | This will create a package of the app in the file "network_tools.tar.gz" (the network toolkit is used in this example): |
19 | 5 | Luke Murphey | |
20 | 5 | Luke Murphey | <pre> |
21 | 5 | Luke Murphey | package: |
22 | 5 | Luke Murphey | [tar] Building tar: /var/folders/61/4v1t_czj3m13m1wbhtlytc00r4lc79/T/lmurphey/network_tools.tar |
23 | 5 | Luke Murphey | [gzip] Building: /Users/lmurphey/Downloads/network_tools.tar.gz |
24 | 5 | Luke Murphey | [delete] Deleting directory /var/folders/61/4v1t_czj3m13m1wbhtlytc00r4lc79/T/lmurphey |
25 | 5 | Luke Murphey | [echo] App network_tools build 1487971707 created: /Users/lmurphey/Downloads/network_tools.tar.gz |
26 | 5 | Luke Murphey | |
27 | 5 | Luke Murphey | BUILD SUCCESSFUL |
28 | 5 | Luke Murphey | Total time: 0 seconds |
29 | 5 | Luke Murphey | </pre> |
30 | 5 | Luke Murphey | |
31 | 2 | Luke Murphey | h2. Requirements |
32 | 2 | Luke Murphey | |
33 | 2 | Luke Murphey | This build script is based around git (e.g. Github, Gitlab, Atlassian Bitbucket). Thus, you will need to customize it if you want to use another type of source code repository. |
34 | 2 | Luke Murphey | |
35 | 2 | Luke Murphey | h2. How do I use it? |
36 | 2 | Luke Murphey | |
37 | 2 | Luke Murphey | h3. Install Java and Ant |
38 | 2 | Luke Murphey | |
39 | 2 | Luke Murphey | Install Java if you don't have it installed. There is a good chance you already have it so you may want to check. |
40 | 2 | Luke Murphey | |
41 | 2 | Luke Murphey | Next, install Ant |
42 | 2 | Luke Murphey | |
43 | 2 | Luke Murphey | h3. Download the build script |
44 | 2 | Luke Murphey | |
45 | 3 | Luke Murphey | Download the file at https://gist.github.com/LukeMurphey/8fd02337805ae8762afb. Place the resulting file in the source-code repository (at the root of the directory). |
46 | 3 | Luke Murphey | |
47 | 2 | Luke Murphey | h3. Create a project |
48 | 2 | Luke Murphey | |
49 | 3 | Luke Murphey | Now, initialize the project but running the following from your source-code directory: |
50 | 3 | Luke Murphey | |
51 | 3 | Luke Murphey | <pre> |
52 | 3 | Luke Murphey | ant -f basebuild.xml |
53 | 3 | Luke Murphey | </pre> |
54 | 3 | Luke Murphey | |
55 | 3 | Luke Murphey | This will run through a short wizard to initialize your project. The script will prompt you for a name for your project. The name should be the folder name of the app (like "website_monitoring"), not the human readable name (which would be something like "Website Monitoring"). |
56 | 3 | Luke Murphey | |
57 | 3 | Luke Murphey | Once it is done, it will create a series of files for you. |
58 | 3 | Luke Murphey | |
59 | 3 | Luke Murphey | Run the following command to test the building of your app: |
60 | 3 | Luke Murphey | |
61 | 3 | Luke Murphey | <pre> |
62 | 3 | Luke Murphey | ant |
63 | 3 | Luke Murphey | </pre> |
64 | 3 | Luke Murphey | |
65 | 3 | Luke Murphey | You should see something noting that your app package was created. |
66 | 3 | Luke Murphey | |
67 | 2 | Luke Murphey | h3. Put in your source code, build your app |
68 | 1 | Luke Murphey | |
69 | 3 | Luke Murphey | Now, make or place your source-code for app in the src/ directory. The code in here should correspond to the contents within your app folder. Thus, your source-code directories will eventually have a structure something like this: |
70 | 3 | Luke Murphey | |
71 | 6 | Luke Murphey | * *lib/* (this is where build dependencies will go, they will be downloaded automatically for you) |
72 | 3 | Luke Murphey | * *src/* (this is where you app code will go) |
73 | 3 | Luke Murphey | ** *default/* (where conf files will go) |
74 | 3 | Luke Murphey | ** *appserver/* (where static web resources go) |
75 | 3 | Luke Murphey | ** *lookups/* (where lookup files go) |
76 | 4 | Luke Murphey | * *basebuild.xml* (contains the main targets you need for building your app that will be used by build.xml) |
77 | 4 | Luke Murphey | * *build.xml* (the main build script; place overrides of the build script in this file) |
78 | 3 | Luke Murphey | * *default.properties* (where properties go that need to be included in the source-code repository) |
79 | 3 | Luke Murphey | * *local.properties* (where properties go that should _not_ be included in the source-code repository) |
80 | 3 | Luke Murphey | |
81 | 3 | Luke Murphey | h3. Configure the build script to install Splunk apps |
82 | 3 | Luke Murphey | |
83 | 2 | Luke Murphey | |
84 | 2 | Luke Murphey | h2. Contents |
85 | 2 | Luke Murphey | |
86 | 2 | Luke Murphey | {{child_pages}} |