Project

General

Profile

Start Here » History » Version 4

Luke Murphey, 03/05/2017 06:15 AM

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 2 Luke Murphey
h2. Requirements
13 2 Luke Murphey
14 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.
15 2 Luke Murphey
16 2 Luke Murphey
h2. How do I use it?
17 2 Luke Murphey
18 2 Luke Murphey
h3. Install Java and Ant
19 2 Luke Murphey
20 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.
21 2 Luke Murphey
22 2 Luke Murphey
Next, install Ant
23 2 Luke Murphey
24 2 Luke Murphey
h3. Download the build script
25 2 Luke Murphey
26 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).
27 3 Luke Murphey
28 2 Luke Murphey
h3. Create a project
29 2 Luke Murphey
30 3 Luke Murphey
Now, initialize the project but running the following from your source-code directory:
31 3 Luke Murphey
32 3 Luke Murphey
<pre>
33 3 Luke Murphey
ant -f basebuild.xml
34 3 Luke Murphey
</pre>
35 3 Luke Murphey
36 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").
37 3 Luke Murphey
38 3 Luke Murphey
Once it is done, it will create a series of files for you.
39 3 Luke Murphey
40 3 Luke Murphey
Run the following command to test the building of your app:
41 3 Luke Murphey
42 3 Luke Murphey
<pre>
43 3 Luke Murphey
ant
44 3 Luke Murphey
</pre>
45 3 Luke Murphey
46 3 Luke Murphey
You should see something noting that your app package was created.
47 3 Luke Murphey
48 2 Luke Murphey
h3. Put in your source code, build your app
49 1 Luke Murphey
50 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:
51 3 Luke Murphey
52 3 Luke Murphey
* *lib/* (this is where build depencies will go, they will be downloaded automatically for you)
53 3 Luke Murphey
* *src/* (this is where you app code will go)
54 3 Luke Murphey
** *default/* (where conf files will go)
55 3 Luke Murphey
** *appserver/* (where static web resources go)
56 3 Luke Murphey
** *lookups/* (where lookup files go)
57 4 Luke Murphey
* *basebuild.xml* (contains the main targets you need for building your app that will be used by build.xml)
58 4 Luke Murphey
* *build.xml* (the main build script; place overrides of the build script in this file)
59 3 Luke Murphey
* *default.properties* (where properties go that need to be included in the source-code repository)
60 3 Luke Murphey
* *local.properties* (where properties go that should _not_ be included in the source-code repository)
61 3 Luke Murphey
62 3 Luke Murphey
h3. Configure the build script to install Splunk apps
63 3 Luke Murphey
64 2 Luke Murphey
65 2 Luke Murphey
h2. Contents
66 2 Luke Murphey
67 2 Luke Murphey
{{child_pages}}