diff --git a/Jenkins/jenkins-deployment.yaml b/Jenkins/jenkins-deployment.yaml index 32e278e..b37b90d 100644 --- a/Jenkins/jenkins-deployment.yaml +++ b/Jenkins/jenkins-deployment.yaml @@ -23,8 +23,13 @@ spec: labels: io.kompose.service: jenkins spec: + securityContext: + fsGroup: 0 + runAsUser: 0 containers: - - image: jenkins/jenkins:2.484 + #- image: jenkins/jenkins:2.484 + #- image: cirolini/jenkins-docker-kubectl + - image: localhost:30400/jenkins-cicd name: jenkins ports: - containerPort: 8080 diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..1241a4d --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,30 @@ +node { + + checkout scm + + // Pega o commit id para ser usado de tag (versionamento) na imagem + sh "git rev-parse --short HEAD > commit-id" + tag = readFile('commit-id').replace("\n", "").replace("\r", "") + + // configura o nome da aplicação, o endereço do repositório e o nome da imagem com a versão + appName = "jenkins-docker-kubectl" + registryHost = "127.0.0.1:30400/" + imageName = "${registryHost}${appName}:${tag}" + + // Configuramos os estágios + + stage "Build" + + def customImage = docker.build("${imageName}") + + stage "Push" + + customImage.push() + + + stage "Deploy PROD" + + input "Deploy to PROD?" + customImage.push('latest') + sh "kubectl set image deployment jenkins jenkins=${imageName} --record" +}