test-initial-repo/Jenkinsfile

79 lines
2.5 KiB
Text
Raw Normal View History

2025-10-31 09:54:44 -03:00
pipeline {
agent any
options { skipDefaultCheckout(true) }
environment {
IMAGE_NAME = 'rd.jenkins'
IMAGE_TAG = 'caro-v1'
CONTAINER_NAME = "${IMAGE_NAME}-container"
AWS_URL = '231670719202.dkr.ecr.sa-east-1.amazonaws.com'
AWS_USER = 'liesa'
AWS_REGION = 'sa-east-1'
AWS_CREDS_ID = 'aws-jenkins'
AWS_REGISTRY = "${AWS_URL}/${AWS_USER}/${IMAGE_NAME}"
AWS_IMAGE = "${AWS_REGISTRY}:${IMAGE_TAG}"
FORGEJO_URL = 'ssh://git@forgejo.test.dev.it.liesa.com.ar'
FORGEJO_OWNER = 'carolina.diaz'
FORGEJO_REPO = 'test-initial-repo.git'
}
2025-10-31 09:54:44 -03:00
stages {
stage('AWS ECR Login') {
steps {
withAWS(credentials: env.AWS_CREDS_ID, region: env.AWS_REGION) {
script {
def accountId = sh(
script: 'set -euo pipefail; aws sts get-caller-identity --query Account --output text',
returnStdout: true
).trim()
env.ECR_REGISTRY = "${accountId}.dkr.ecr.${env.AWS_REGION}.amazonaws.com"
}
sh '''
set -euo pipefail
echo "Logging in to AWS ECR: ${ECR_REGISTRY}"
aws ecr get-login-password --region "$AWS_REGION" \
| docker login --username AWS --password-stdin "$ECR_REGISTRY"
'''
}
}
}
stage('Checkout') {
steps {
cleanWs()
checkout scm
sh '''
git rev-parse --short HEAD
git status
git submodule update --init --recursive
git submodule status || true
'''
}
}
stage('Build Image') {
2025-10-31 09:54:44 -03:00
steps {
sh "echo ${AWS_REGISTRY}:${IMAGE_TAG}"
2025-10-31 09:54:44 -03:00
script {
docker.build("${AWS_REGISTRY}:${IMAGE_TAG}", '-f Dockerfile ./src/worker')
2025-10-31 09:54:44 -03:00
}
}
}
stage('Push Image') {
steps {
sh 'docker push "${AWS_REGISTRY}:${IMAGE_TAG}"'
}
}
stage('Pull Image') {
steps {
sh 'docker pull "${AWS_REGISTRY}:${IMAGE_TAG}"'
}
}
2025-10-31 09:54:44 -03:00
}
}