Update Jenkinsfile
This commit is contained in:
parent
b84e7dcac2
commit
e384b72c57
1 changed files with 25 additions and 7 deletions
30
Jenkinsfile
vendored
30
Jenkinsfile
vendored
|
|
@ -2,26 +2,44 @@ pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
IMAGE_NAME = 'test-img'
|
IMAGE_NAME = 'rd.jenkins'
|
||||||
DOCKERHUB_USER = 'ramonvasquezliesa'
|
AWS_USER = 'liesa'
|
||||||
DOCKERHUB_REPO = "${DOCKERHUB_USER}/${IMAGE_NAME}"
|
AWS_REPO = "${AWS_USER}/${IMAGE_NAME}"
|
||||||
|
AWS_URL = '231670719202.dkr.ecr.sa-east-1.amazonaws.com'
|
||||||
TAG = 'latest'
|
TAG = 'latest'
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
stage('Checkout (with submodules)') {
|
||||||
|
steps {
|
||||||
|
checkout(scmGit(
|
||||||
|
branches: [[name: '*/main']],
|
||||||
|
userRemoteConfigs: [[
|
||||||
|
url: 'https://stalked-noegenetic-amari.ngrok-free.dev/hermes/pl-1.git',
|
||||||
|
credentialsId: 'hermes-forgejo-local'
|
||||||
|
]]
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stage('Build Image') {
|
stage('Build Image') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
docker.build("${DOCKERHUB_REPO}:${TAG}", '-f Dockerfile .')
|
docker.build("${AWS_REPO}:${TAG}", '-f Dockerfile .')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Push Image') {
|
stage('Push Image') {
|
||||||
steps {
|
steps {
|
||||||
|
sh '''
|
||||||
|
set -eu pipefail
|
||||||
|
aws ecr get-login-password --region sa-east-1 | docker login --username AWS --password-stdin $AWS_URL
|
||||||
|
'''
|
||||||
|
|
||||||
script {
|
script {
|
||||||
docker.withRegistry('https://index.docker.io/v1/', 'dockerhub-credentials') {
|
docker.withRegistry("http://${AWS_URL}", 'ecr:sa-east-1:aws-prod') {
|
||||||
docker.image("${DOCKERHUB_REPO}:${TAG}").push()
|
docker.image("${AWS_REPO}:${TAG}").push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue