Adds clair and sonar scanner
This commit is contained in:
parent
f384faad35
commit
8cc630e1e4
76
build-clair.jenkins
Normal file
76
build-clair.jenkins
Normal file
@ -0,0 +1,76 @@
|
||||
def label = "jenkins-${UUID.randomUUID().toString()}"
|
||||
|
||||
def repository = "registry.test-chamber-13.lan:8443"
|
||||
def kanikoImage = "${repository}/nhyatt/kaniko:latest"
|
||||
def repositoryCreds = "quay-repository-creds"
|
||||
|
||||
def caName = "test-chamber-13.lan.root.crt"
|
||||
def caContent = """
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICLTCCAbOgAwIBAgIDAYagMAoGCCqGSM49BAMEME0xCzAJBgNVBAYTAlVTMScw
|
||||
JQYDVQQKDB5UZXN0IENoYW1iZXIgMTMgVHJ1c3QgU2VydmljZXMxFTATBgNVBAMM
|
||||
DFRDMTMgUm9vdCBSMTAgFw0xOTAxMDEwMDAwMDBaGA8yMDUwMDEwMTAwMDAwMFow
|
||||
TTELMAkGA1UEBhMCVVMxJzAlBgNVBAoMHlRlc3QgQ2hhbWJlciAxMyBUcnVzdCBT
|
||||
ZXJ2aWNlczEVMBMGA1UEAwwMVEMxMyBSb290IFIxMHYwEAYHKoZIzj0CAQYFK4EE
|
||||
ACIDYgAE8+/J1ECc0VHxTtGXFLnHJ3NGZ2SW38pp9wI58L5EQbHRLiezYuvkUbI/
|
||||
XGJjLnFdpgjo7W1FFlyhx5ITlCstUX5Sn9bLZiA0+mE0n6b8VwhXwkHlnIeRo7od
|
||||
Zu/OfSFjo2MwYTAdBgNVHQ4EFgQUrGqUJhyRp93wXF645VNtYatRk/AwHwYDVR0j
|
||||
BBgwFoAUrGqUJhyRp93wXF645VNtYatRk/AwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
|
||||
HQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwQDaAAwZQIxAJdgskimDJkf/MGVRrKotmNC
|
||||
xdH/UVQfQppjIR9FAiGeFDr47thclYrzIL6yCkV7nwIwYjf3MbOm/yWblzqe3Uyw
|
||||
UOemMEg3PjcKNsN65W2WVon5HIZx2XVfGRPjf5ZTVWzZ
|
||||
-----END CERTIFICATE-----
|
||||
"""
|
||||
|
||||
podTemplate(
|
||||
label: label,
|
||||
name: "pipeline-worker",
|
||||
yaml: """---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
spec:
|
||||
containers:
|
||||
- name: kaniko
|
||||
image: ${kanikoImage}
|
||||
tty: true
|
||||
command:
|
||||
- /busybox/cat
|
||||
""",
|
||||
) {
|
||||
node (label) {
|
||||
def workspace = pwd()
|
||||
|
||||
stage ("Prepare Kaniko") {
|
||||
container ("kaniko") {
|
||||
withCredentials([usernameColonPassword(
|
||||
credentialsId: repositoryCreds,
|
||||
variable: "dCreds",
|
||||
)]) {
|
||||
def dockerJSON = """{
|
||||
"auths": {
|
||||
"${repository}": {
|
||||
"auth": "${dcreds.bytes.encodeBase64().toString()}"
|
||||
}
|
||||
}
|
||||
}"""
|
||||
sh """
|
||||
set +x
|
||||
echo '${dockerJSON}' > /kaniko/.docker/config.json
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage("Kaniko Build & Push") {
|
||||
container ("kaniko") {
|
||||
def dockerfile = """
|
||||
FROM quay.io/coreos/clair:v2.1.4
|
||||
RUN update-ca-certificates --fresh
|
||||
"""
|
||||
writeFile (file: workspace + "/${caName}", text: caContent)
|
||||
writeFile (file: workspace + "/Dockerfile", text: dockerfile)
|
||||
sh "/kaniko/executor --context \"${workspace}\" -f \"${workspace}/Dockerfile\" --destination \"${repository}/nhyatt/clair:latest\""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
74
build-sonarqube.jenkins
Normal file
74
build-sonarqube.jenkins
Normal file
@ -0,0 +1,74 @@
|
||||
def label = "jenkins-${UUID.randomUUID().toString()}"
|
||||
|
||||
def repository = "registry.test-chamber-13.lan:8443"
|
||||
def kanikoImage = "${repository}/nhyatt/kaniko:latest"
|
||||
def repositoryCreds = "quay-repository-creds"
|
||||
|
||||
def caName = "test-chamber-13.lan.root.crt"
|
||||
def caContent = """
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICLTCCAbOgAwIBAgIDAYagMAoGCCqGSM49BAMEME0xCzAJBgNVBAYTAlVTMScw
|
||||
JQYDVQQKDB5UZXN0IENoYW1iZXIgMTMgVHJ1c3QgU2VydmljZXMxFTATBgNVBAMM
|
||||
DFRDMTMgUm9vdCBSMTAgFw0xOTAxMDEwMDAwMDBaGA8yMDUwMDEwMTAwMDAwMFow
|
||||
TTELMAkGA1UEBhMCVVMxJzAlBgNVBAoMHlRlc3QgQ2hhbWJlciAxMyBUcnVzdCBT
|
||||
ZXJ2aWNlczEVMBMGA1UEAwwMVEMxMyBSb290IFIxMHYwEAYHKoZIzj0CAQYFK4EE
|
||||
ACIDYgAE8+/J1ECc0VHxTtGXFLnHJ3NGZ2SW38pp9wI58L5EQbHRLiezYuvkUbI/
|
||||
XGJjLnFdpgjo7W1FFlyhx5ITlCstUX5Sn9bLZiA0+mE0n6b8VwhXwkHlnIeRo7od
|
||||
Zu/OfSFjo2MwYTAdBgNVHQ4EFgQUrGqUJhyRp93wXF645VNtYatRk/AwHwYDVR0j
|
||||
BBgwFoAUrGqUJhyRp93wXF645VNtYatRk/AwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
|
||||
HQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwQDaAAwZQIxAJdgskimDJkf/MGVRrKotmNC
|
||||
xdH/UVQfQppjIR9FAiGeFDr47thclYrzIL6yCkV7nwIwYjf3MbOm/yWblzqe3Uyw
|
||||
UOemMEg3PjcKNsN65W2WVon5HIZx2XVfGRPjf5ZTVWzZ
|
||||
-----END CERTIFICATE-----
|
||||
"""
|
||||
|
||||
podTemplate(
|
||||
label: label,
|
||||
name: "pipeline-worker",
|
||||
yaml: """---
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
spec:
|
||||
containers:
|
||||
- name: kaniko
|
||||
image: ${kanikoImage}
|
||||
tty: true
|
||||
command:
|
||||
- /busybox/cat
|
||||
""",
|
||||
) {
|
||||
node (label) {
|
||||
def workspace = pwd()
|
||||
|
||||
stage ("Prepare Kaniko") {
|
||||
container ("kaniko") {
|
||||
withCredentials([usernameColonPassword(
|
||||
credentialsId: repositoryCreds,
|
||||
variable: "dCreds",
|
||||
)]) {
|
||||
def dockerJSON = """{
|
||||
"auths": {
|
||||
"${repository}": {
|
||||
"auth": "${dcreds.bytes.encodeBase64().toString()}"
|
||||
}
|
||||
}
|
||||
}"""
|
||||
sh """
|
||||
set +x
|
||||
echo '${dockerJSON}' > /kaniko/.docker/config.json
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage("Kaniko Build & Push") {
|
||||
container ("kaniko") {
|
||||
def dockerfile = """
|
||||
"""
|
||||
writeFile (file: workspace + "/${caName}", text: caContent)
|
||||
writeFile (file: workspace + "/Dockerfile", text: dockerfile)
|
||||
sh "/kaniko/executor --context \"${workspace}\" -f \"${workspace}/Dockerfile\" --destination \"${repository}/nhyatt/sonarscanner:latest\""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user