add docker files

This commit is contained in:
canguilieme julien 2024-10-06 18:57:43 +02:00
parent 6d501f83a8
commit e2f5aa84d5

14
Jenkinsfile vendored
View File

@ -5,35 +5,35 @@ pipeline {
stage('Build') { stage('Build') {
steps { steps {
echo 'Compilation du code...' echo 'Compilation du code...'
// Ajoutez ici vos commandes de build, par exemple : sh 'mvn clean install' // Add your build commands here
} }
} }
stage('Test') { stage('Test') {
steps { steps {
echo 'Exécution des tests...' echo 'Exécution des tests...'
// Ajoutez ici vos commandes de test // Add your test commands here
} }
} }
stage('Deploy') { stage('Deploy') {
steps { steps {
echo 'Déploiement sur Portainer...' echo 'Déploiement sur Portainer...'
// Obtenir un jeton d'authentification de Portainer // Obtain an authentication token from Portainer
withCredentials([usernamePassword(credentialsId: 'test', usernameVariable: 'PORTAINER_USERNAME', passwordVariable: 'PORTAINER_PASSWORD')]) { withCredentials([usernamePassword(credentialsId: 'portainer-credentials', usernameVariable: 'PORTAINER_USERNAME', passwordVariable: 'PORTAINER_PASSWORD')]) {
script { script {
def response = httpRequest httpMode: 'POST', def response = httpRequest httpMode: 'POST',
contentType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON',
url: "http://portainer.canguidev.fr/api/auth", url: "http://portainer.canguidev.fr/api/auth",
requestBody: "{\"Username\":\"admin\",\"Password\":\"j6+M&5jKwrCf+:+\"}" requestBody: "{\"Username\":\"${PORTAINER_USERNAME}\",\"Password\":\"${PORTAINER_PASSWORD}\"}"
def json = readJSON text: response.content def json = readJSON text: response.content
env.PORTAINER_TOKEN = json.jwt env.PORTAINER_TOKEN = json.jwt
} }
} }
// Déployer la stack sur Portainer // Deploy the stack on Portainer using the obtained token
httpRequest httpMode: 'PUT', httpRequest httpMode: 'PUT',
customHeaders: [[name: 'Authorization', value: "Bearer ptr_2bbjwbBGravgP2gERwL5h/QNq9gmBT/41fYjtjbb07k="]], customHeaders: [[name: 'Authorization', value: "Bearer ${env.PORTAINER_TOKEN}"]],
url: "http://portainer.canguidev.fr/api/stacks/canguidev/deploy", url: "http://portainer.canguidev.fr/api/stacks/canguidev/deploy",
contentType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON',
requestBody: '{"Prune": true}' requestBody: '{"Prune": true}'