46 lines
1.7 KiB
Groovy
46 lines
1.7 KiB
Groovy
pipeline {
|
|
agent any
|
|
|
|
stages {
|
|
stage('Build') {
|
|
steps {
|
|
echo 'Compilation du code...'
|
|
// Ajoutez ici vos commandes de build, par exemple : sh 'mvn clean install'
|
|
}
|
|
}
|
|
stage('Test') {
|
|
steps {
|
|
echo 'Exécution des tests...'
|
|
// Ajoutez ici vos commandes de test
|
|
}
|
|
}
|
|
stage('Deploy') {
|
|
steps {
|
|
echo 'Déploiement sur Portainer...'
|
|
|
|
// Obtenir un jeton d'authentification de Portainer
|
|
withCredentials([usernamePassword(credentialsId: 'test', usernameVariable: 'PORTAINER_USERNAME', passwordVariable: 'PORTAINER_PASSWORD')]) {
|
|
script {
|
|
def response = httpRequest httpMode: 'POST',
|
|
contentType: 'APPLICATION_JSON',
|
|
url: "http://portainer.canguidev.fr/api/auth",
|
|
requestBody: "{\"Username\":\"admin\",\"Password\":\"j6+M&5jKwrCf+:+\"}"
|
|
|
|
def json = readJSON text: response.content
|
|
env.PORTAINER_TOKEN = json.jwt
|
|
}
|
|
}
|
|
|
|
// Déployer la stack sur Portainer
|
|
httpRequest httpMode: 'PUT',
|
|
customHeaders: [[name: 'Authorization', value: "Bearer ptr_2bbjwbBGravgP2gERwL5h/QNq9gmBT/41fYjtjbb07k="]],
|
|
url: "http://portainer.canguidev.fr/api/stacks/canguidev/deploy",
|
|
contentType: 'APPLICATION_JSON',
|
|
requestBody: '{"Prune": true}'
|
|
|
|
echo 'Déploiement terminé.'
|
|
}
|
|
}
|
|
}
|
|
}
|