-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
executable file
·44 lines (44 loc) · 1.5 KB
/
Jenkinsfile
File metadata and controls
executable file
·44 lines (44 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
pipeline {
agent any
environment {
HARBOR_REGISTRY = 'oci.external.infra.unxwares.com'
HARBOR_PROJECT = 'websites'
APP_NAME = 'cloud-website'
IMAGE_TAG = "v${env.BUILD_NUMBER}"
FULL_IMAGE_NAME = "${HARBOR_REGISTRY}/${HARBOR_PROJECT}/${APP_NAME}:${IMAGE_TAG}"
HARBOR_CREDS_ID = 'harbor-creds'
}
stages {
stage('Checkout Code') {
steps {
checkout scm
}
}
stage('Build Docker Image') {
steps {
script {
echo "Construction de l.image Laravel Cloud Website..."
withCredentials([usernamePassword(credentialsId: 'unxwares-npm-token', passwordVariable: 'NPM_PASSWORD', usernameVariable: 'NPM_USERNAME')]) {
appImage = docker.build("${FULL_IMAGE_NAME}", "--network=host --build-arg NPM_USERNAME=${NPM_USERNAME} --build-arg NPM_PASSWORD=${NPM_PASSWORD} -f Dockerfile .")
}
}
}
}
stage('Push to Harbor') {
steps {
script {
echo "Envoi de l'image vers Harbor..."
docker.withRegistry("https://${HARBOR_REGISTRY}", "${HARBOR_CREDS_ID}") {
appImage.push()
appImage.push("latest")
}
}
}
}
}
post {
always {
sh "docker rmi ${FULL_IMAGE_NAME} || true"
}
}
}