Gitlab CI Gradle Plugin
GitlabCI validator is a gradle plugin to validate .gitlab-ci.yml
as soon as posible.
If you have a .gitlab-ci.yml
and include the validator task, it checks the file againts Gitlab and if the
file has error the task fails (showing what’s the reason of the error)
Plugin
plugins {
id 'com.puravida.gradle.gitlabci-validator'
}
Task validator
validateGitlabCI{
}
You can choose against what api validate your .gitlabci.yml
using the gitlabCi
extension
gitlabCI{
api 'v4'
}
validateGitlabCI{
}
you can include the task in the dependsOn of your build or compile task, for example,
in order to be sure your .gitlab-ci.yml is valid or you can install a hook into your git push (see
InstallHookTask section)
|
Install Hook Task
If you don’t want to include the task validateGitlabCI
as a dependsOn of your build
task
then you need to call manually it, for example every time you change the .gitlab-ci.yml
file.
But if you are as lazy as me you can install a pre-push git hook and run the validation before
push anything into yout Gitlab repository. This can be easily done executing
the installValidateGitlabCIHook
task only one time
./gradlew installValidateGitlabCIHook
Once executed this task your git repo will have a pre-push hook running the validateGitlabCI
for you
every time you try to do a push. If you made some mistake into your .gitlab-ci.yml
the push fails
#!/bin/sh
./gradlew validateGitlabCI