-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from stemdo-labs/develop
Develop
- Loading branch information
Showing
17 changed files
with
411 additions
and
219 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
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,117 @@ | ||
pipeline { | ||
agent { | ||
kubernetes { | ||
label 'jenkins-jenkins-agent' | ||
defaultContainer 'dind' | ||
} | ||
} | ||
|
||
environment { | ||
APIKEY_IBM_ACAJAS = credentials('APIKEY_IBM_ACAJAS') | ||
} | ||
|
||
parameters { | ||
string(name: 'desarrollo', defaultValue: 'develop-backend') | ||
string(name: 'entorno', defaultValue: 'develop') | ||
string(name: 'repo', defaultValue: 'repositorio') | ||
} | ||
|
||
stages { | ||
stage('Clonar otro repositorio') { | ||
steps { | ||
script { | ||
dir('repo') { | ||
git branch: 'develop', url: """https://github.com/stemdo-labs/${repo}""" | ||
} | ||
} | ||
} | ||
} | ||
|
||
stage('Extraer versión') { | ||
steps { | ||
script { | ||
dir('repo') { | ||
if (repo.contains('backend')) { | ||
def version = sh(script: "grep -o '<version>[^<]*' pom.xml | sed 's/<version>//' | sed -n '2p'", returnStdout: true).trim() | ||
env.VERSION = version | ||
echo "Versión (backend): ${version}" | ||
} else if (repo.contains('frontend')) { | ||
def json = readJSON file: 'package.json' | ||
def version = json.version | ||
env.VERSION = version | ||
echo "Versión (frontend): ${version}" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
stage('Cargar imagen') { | ||
steps { | ||
script { | ||
def imageName = sh(script: "echo uk.icr.io/acajas-cr-namespace/${desarrollo}:${version}", returnStdout: true).trim() | ||
env.IMAGE_NAME = imageName | ||
echo "Image name: ${env.IMAGE_NAME}" | ||
} | ||
} | ||
} | ||
|
||
stage('Modificar nginx.conf según el entorno') { | ||
steps { | ||
script { | ||
dir('repo') { | ||
if (repo.contains('frontend')) { | ||
sh """ | ||
sed "s/ENVIRONMENT/${entorno}/g" nginx.conf.template > nginx.conf | ||
cat nginx.conf | ||
""" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
stage('Construir imagen Docker') { | ||
steps { | ||
script { | ||
dir('repo') { | ||
sh """docker build -t ${env.IMAGE_NAME} .""" | ||
} | ||
} | ||
} | ||
} | ||
|
||
stage('Instalar IBM CLI') { | ||
steps { | ||
sh 'curl -fsSL https://clis.cloud.ibm.com/install/linux | sh' | ||
} | ||
} | ||
|
||
stage('IBM Cloud Login') { | ||
steps { | ||
sh ''' | ||
ibmcloud login --apikey ${APIKEY_IBM_ACAJAS} -r eu-gb | ||
ibmcloud target -g Stemdo_Sandbox | ||
''' | ||
} | ||
} | ||
|
||
stage('Instalar Plugin CR') { | ||
steps { | ||
sh 'ibmcloud plugin install container-registry' | ||
} | ||
} | ||
|
||
stage('Login en IBM Container Registry') { | ||
steps { | ||
sh 'ibmcloud cr login --client docker' | ||
} | ||
} | ||
|
||
stage('Push de la imagen') { | ||
steps { | ||
sh """docker push ${env.IMAGE_NAME}""" | ||
} | ||
} | ||
} | ||
} |
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,13 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: jenkins-pv-acajas | ||
spec: | ||
capacity: | ||
storage: 20Gi | ||
accessModes: | ||
- ReadWriteMany | ||
persistentVolumeReclaimPolicy: Retain | ||
hostPath: | ||
path: /mnt/data/jenkins | ||
storageClassName: jenkins |
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,11 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: jenkins-pvc-acajas | ||
spec: | ||
storageClassName: jenkins | ||
accessModes: | ||
- ReadWriteMany | ||
resources: | ||
requests: | ||
storage: 20Gi |
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,2 +1,29 @@ | ||
rbac: | ||
useOpenShiftNonRootSCC: true | ||
useOpenShiftNonRootSCC: true | ||
controller: | ||
numExecutors: 7 | ||
route: | ||
enabled: true | ||
|
||
agent: | ||
additionalContainers: | ||
- sideContainerName: dind | ||
image: | ||
repository: jooeel98/agente-jenkins | ||
tag: 0.0.1 | ||
command: dockerd-entrypoint.sh | ||
args: "" | ||
privileged: true | ||
resources: | ||
requests: | ||
cpu: 500m | ||
memory: 1Gi | ||
limits: | ||
cpu: 1 | ||
memory: 2Gi | ||
|
||
# persistence: | ||
# enabled: true | ||
# existingClaim: jenkins-pvc | ||
# storageClass: "jenkins" | ||
# size: 20Gi |
Oops, something went wrong.