- Lab
- A Cloud Guru
Creating Build Automation with Gradle
Build Automation is an important part of continuous integration, and a necessary component of many automated pipelines. Gradle is a powerful build automation tool. This learning activity will guide you through the process of implementing a basic gradle build. After completing this activity, you should have a working knowledge of the basics of build automation in gradle.
Path Info
Table of Contents
-
Challenge
Your personal fork of the git repository is cloned to the cloud server
You need to clone your personal fork of the sample git repository to the cloud server. Make sure you perform the clone from your home directory.
You can do so like this:
cd ~/ git clone [email protected]:<your_username>/cicd-pipeline-train-schedule-gradle.git
-
Challenge
You initialized the project as a gradle project
Once you have cloned the git repo to your home directory,
cd
into the repo directory and then initialize the gradle build.cd ~/cicd-pipeline-train-schedule-gradle ./gradlew init
-
Challenge
Your gradle build generates a zip archive of the application in `dist/trainSchedule.zip`
The gradle build should generate an archive of the application in dist/trainSchedule.zip.
You can do this by adding a task to create this archive to build.gradle and ensuring the build task depends on it.
task zip(type: Zip) { from ('.') { include "*" include "bin/**" include "data/**" include "node_modules/**" include "public/**" include "routes/**" include "views/**" } destinationDir(file("dist")) baseName "trainSchedule" } build.dependsOn zip zip.dependsOn npm_build
The full build.gradle file should look like this :
plugins { id("com.github.node-gradle.node") version "2.2.4" } node { version = '9.11.2' download = true } task build task zip(type: Zip) { from ('.') { include "*" include "bin/**" include "data/**" include "node_modules/**" include "public/**" include "routes/**" include "views/**" } destinationDir(file("dist")) baseName "trainSchedule" } build.dependsOn zip zip.dependsOn npm_build build.dependsOn npm_build npm_build.dependsOn npmInstall npm_build.dependsOn npm_test npm_test.dependsOn npmInstall
Then, execute the gradle build to generate the archive:
./gradlew build
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.