-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
81 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.cloudogu.ces.cesbuildlib | ||
|
||
class Dockerfile { | ||
private script | ||
|
||
Dockerfile(script) { | ||
this.script = script | ||
} | ||
|
||
/** | ||
* Lints the Dockerfile with hadolint using a configuration file | ||
* | ||
* To configure hadelint, add a ".hadolint.yaml" file to your working directory | ||
* See https://github.com/hadolint/hadolint#configure | ||
* | ||
* @param dockerfile Path to the Dockerfile that should be linted | ||
* @param configuration Path to the hadolint configuration file | ||
* @param hadolintVersion Version of the hadolint/hadolint container image | ||
*/ | ||
void lintWithConfig(String dockerfile = "Dockerfile", String configuration = ".hadolint.yaml", hadolintVersion = "latest-debian"){ | ||
script.docker.image("hadolint/hadolint:${hadolintVersion}").inside(){ | ||
script.sh "hadolint --no-color -c ${configuration} ${dockerfile}" | ||
} | ||
} | ||
|
||
/** | ||
* Lints the Dockerfile with the latest version of hadolint | ||
* Only fails on errors, ignores warnings etc. | ||
* Trusts registries docker.io, gcr.io and registry.cloudogu.com | ||
* | ||
* @param dockerfile Path to the Dockerfile that should be linted | ||
* @param hadolintVersion Version of the hadolint/hadolint container image | ||
*/ | ||
void lint(String dockerfile = "Dockerfile", hadolintVersion = "latest-debian"){ | ||
script.docker.image("hadolint/hadolint:${hadolintVersion}").inside(){ | ||
script.sh "hadolint -t error --no-color --trusted-registry docker.io --trusted-registry gcr.io --trusted-registry registry.cloudogu.com ${dockerfile}" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.cloudogu.ces.cesbuildlib | ||
|
||
@Deprecated | ||
def call(String dockerfile = "Dockerfile") { | ||
// only latest version available | ||
docker.image('projectatomic/dockerfile-lint:latest').inside({ | ||
sh "dockerfile_lint -p -f ${dockerfile}" | ||
}) | ||
docker.image('hadolint/hadolint:latest-debian').inside(){ | ||
sh "hadolint --no-color -t error " + | ||
"--trusted-registry docker.io --trusted-registry gcr.io --trusted-registry registry.cloudogu.com " + | ||
"${WORKSPACE}/${dockerfile}" | ||
} | ||
} |