add docker files
This commit is contained in:
parent
2d7425bd07
commit
68cffca2e0
@ -1,34 +0,0 @@
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
build-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo "Compilation du code..."
|
||||
# Ajoutez vos commandes de build ici
|
||||
|
||||
test-job:
|
||||
stage: test
|
||||
script:
|
||||
- echo "Exécution des tests..."
|
||||
# Ajoutez vos commandes de test ici
|
||||
|
||||
deploy-job:
|
||||
stage: deploy
|
||||
script:
|
||||
- echo "Déploiement sur Portainer..."
|
||||
- |
|
||||
TOKEN=$(curl -s -X POST -d "{\"Username\":\"$PORTAINER_USERNAME\",\"Password\":\"$PORTAINER_PASSWORD\"}" \
|
||||
-H "Content-Type: application/json" http://$PORTAINER_URL/api/auth | jq -r .jwt)
|
||||
- |
|
||||
curl -s -X PUT \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"Prune": true}' \
|
||||
http://$PORTAINER_URL/api/stacks/$STACK_ID/deploy
|
||||
- echo "Déploiement terminé."
|
||||
dependencies:
|
||||
- build-job
|
||||
- test-job
|
||||
45
Jenkinsfile
vendored
Normal file
45
Jenkinsfile
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
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: 'portainer-credentials', 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é.'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user