-
Notifications
You must be signed in to change notification settings - Fork 45
Specification for lifecycles file
This is the general description of the supported language format listing default commands. This will be used to generate default commands depending on the language and files detected in the repository.
{
"language": {
"friendlyName": "my friendly name",
"defaultKey": "somekey",
"somekey": {
"fileExistsCondition": ["/root/path", "somefile"],
"fallbackKey": "some other key",
"env": "export somevar=value",
"before_install": "some command",
"install": "some command",
"before_script": "some command",
"script": "some command",
"after_success": "some command",
"after_failure": "some command",
"after_script": "some command",
},
"some other key": {
"fileExistsCondition": ["/root/path", "somefile"],
}
}
}-
language- is the language that the commands are set up for. e.g.groovy,python,ruby,java, etc. The language is the root key of the object and will be used to look up default commands for all of the different command generation cases. The following keys fall under the language. Validation: This key is required. -
friendlyName- A friendly name which can be used to reference the language. This is sometimes different than the key used to reference the language. Provides a user friendly means of printing out the language being used. e.g. Instead ofcppit isC++. Validation: This key is required. -
defaultKey- This is the default key which will be used to look up the default commands to be generated. Validation: This key is required. The value of this key must exist as another key in the same level as this key. e.g."somekey". -
somekey- This key is one or more keys in which will, by convention, be named after the build tool the commands are related to. e.g.gradle,ant,maven, etc. The sub-keys are related to the Travis Build Lifecycle. Validation: This key is required if it is referenced by any other keys (i.e. referenced bydefaultKeyor afallbackKey). 1.fileExistsCondition- This contains a list with only two elements. The first element is a folder path relative to the root of the git repository. The second element is the name of a file to check for existence. IffileExistsConditionkey does not exist then jervis uses the default commands in this parent key. IffileExistsConditionkey does exist AND the file exists then jervis uses the default commands in this parent key. IffileExistsConditionkey does exist AND the file does not exist then it will use thefallbackKeyto try to fall back to another key. IffileExistsConditionkey does exist AND the file does not exist ANDfallbackKeydoes not exist then an exception will be thrown because this will be treated as a means to not continue. Validation: This key is optional. This key is required iffallbackKeyexists. The first character of the first element must always be a/. The length of this list must always be2. 1.fallbackKey- Reference a key that the program should fall back to for other defaults. Validation: This key is optional. If this key exists then the fallback key,"some other key", must exist.fileExistsConditionbecomes a required key if this key is used. 1.env- Used to set any environment variables which will be included before thebefore_installstep is executed. Validation: This key is optional. 1.before_install- The contents of this key may either be a string of commands to execute (one line). IfreadFile(/path/file.sh)is used then it will read the file off of the filesystem. See below for a better description ofreadFile(). See description in the Travis Build Lifecycle. Validation: This key is optional. IfreadFile(/path/to/file.sh)is used then the first character inside of the parenthesis must be a/. 1.install- The contents of this key may either be a string of commands to execute (one line). IfreadFile(/path/file.sh)is used then it will read the file off of the filesystem. See below for a better description ofreadFile(). See description in the Travis Build Lifecycle. Validation: This key is optional. IfreadFile(/path/to/file.sh)is used then the first character inside of the parenthesis must be a/. 1.before_script- The contents of this key may either be a string of commands to execute (one line). IfreadFile(/path/file.sh)is used then it will read the file off of the filesystem. See below for a better description ofreadFile(). See description in the Travis Build Lifecycle. Validation: This key is optional. IfreadFile(/path/to/file.sh)is used then the first character inside of the parenthesis must be a/. 1.script- The contents of this key may either be a string of commands to execute (one line). IfreadFile(/path/file.sh)is used then it will read the file off of the filesystem. See below for a better description ofreadFile(). See description in the Travis Build Lifecycle. Validation: This key is optional. IfreadFile(/path/to/file.sh)is used then the first character inside of the parenthesis must be a/. 1.after_success- The contents of this key may either be a string of commands to execute (one line). IfreadFile(/path/file.sh)is used then it will read the file off of the filesystem. See below for a better description ofreadFile(). See description in the Travis Build Lifecycle. Validation: This key is optional. IfreadFile(/path/to/file.sh)is used then the first character inside of the parenthesis must be a/. 1.after_failure- The contents of this key may either be a string of commands to execute (one line). IfreadFile(/path/file.sh)is used then it will read the file off of the filesystem. See below for a better description ofreadFile(). See description in the Travis Build Lifecycle. Validation: This key is optional. IfreadFile(/path/to/file.sh)is used then the first character inside of the parenthesis must be a/. 1.after_script- The contents of this key may either be a string of commands to execute (one line). IfreadFile(/path/file.sh)is used then it will read the file off of the filesystem. See below for a better description ofreadFile(). See description in the Travis Build Lifecycle. Validation: This key is optional. IfreadFile(/path/to/file.sh)is used then the first character inside of the parenthesis must be a/.
If readFile(/somefile) is used then it should read the file from the filesystem relative to the root of the repository. That logic would look something like this...
x="readFile(/path/to/file.sh)"
if (x[0..8] == 'readFile(') {
//should print "/path/to/file.sh"
println "Read the file ${x[9..-2]}"
}
else {
println "Handle the string as a script on a single line."
}Get the git repository root path.
def process = "git rev-parse --show-toplevel".execute()
def git_root = process.text.trim()
process = null
println "Git root is: ${git_root}"Combining the previous two examples.
def process = "git rev-parse --show-toplevel".execute()
def git_root = process.text.trim()
process = null
def x="readFile(/src/main/firstjob.dsl)"
test = []
if (x[0..8] == 'readFile(') {
//should print "/path/to/file.sh"
File y = new File("${git_root}${x[9..-2]}")
y.eachLine {
test << it
}
}
else {
println "Handle the string as a script on a single line."
}
println test.class
//should be class java.util.ArrayListHere's an example of our supported language key when we're supporting just the groovy language. This example is based on the "Building a Groovy Project" Travis CI Documentation. In the groovy project docs it first tries gradle, then falls back to maven, and finally falls back to ant. The following represents that.
{
"groovy": {
"friendlyName": "Groovy",
"defaultKey": "gradle",
"gradle": {
"fileExistsCondition": ["/", "build.gradle"],
"fallbackKey": "maven",
"install": "gradle assemble",
"script": "gradle check"
},
"maven": {
"fileExistsCondition": ["/", "pom.xml"],
"fallbackKey": "ant",
"install": "mvn install -DskipTests=true",
"script": "mvn test",
},
"ant": {
"fileExistsCondition": ["/", "build.xml"],
"script": "ant test",
}
}
}Now we're going to add another language, ruby, to the previous example. This example is based on the "Building a Ruby Project" Travis CI Documentation.
{
"groovy": {
"friendlyName": "Groovy",
"defaultKey": "gradle",
"gradle": {
"fileExistsCondition": ["/", "build.gradle"],
"fallbackKey": "maven",
"install": "gradle assemble",
"script": "gradle check"
},
"maven": {
"fileExistsCondition": ["/", "pom.xml"],
"fallbackKey": "ant",
"install": "mvn install -DskipTests=true",
"script": "mvn test",
},
"ant": {
"fileExistsCondition": ["/", "build.xml"],
"script": "ant test",
}
},
"ruby": {
"friendlyName": "Ruby",
"defaultKey": "rake",
"rake": {
"env": "export BUNDLE_GEMFILE=$PWD/Gemfile",
"install": "bundle install --jobs=3 --retry=3",
"script": "bundle exec rake"
}
}
}The groovy and ruby language keys are independent of each other. It depends on the language: groovy or language: ruby setting in the .travis.yml.
- Build overview
- Supported languages
- Supported build tools
- Publish results
- Additional topics:
- Quickstart
- Background information
- Knowledge checklist
- Required Jenkins Plugins
- Labels for Jenkins Agents
- Key security concepts
- Operationalize Jenkins
- High availability
- Disaster recovery
- Pipeline support
- Extending support