From f0b10497594b8cd17a895917db64365f96f9b2ff Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Tue, 19 Aug 2025 16:27:23 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1ado=20Jenkinsfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkins/jenkins-deployment.yaml | 7 ++++++- Jenkinsfile | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 Jenkinsfile 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" +}