add docker files
This commit is contained in:
parent
e2f5aa84d5
commit
e00cc3ba84
21
Jenkinsfile
vendored
21
Jenkinsfile
vendored
@ -21,10 +21,20 @@ pipeline {
|
|||||||
// Obtain an authentication token from Portainer
|
// Obtain an authentication token from Portainer
|
||||||
withCredentials([usernamePassword(credentialsId: 'portainer-credentials', usernameVariable: 'PORTAINER_USERNAME', passwordVariable: 'PORTAINER_PASSWORD')]) {
|
withCredentials([usernamePassword(credentialsId: 'portainer-credentials', usernameVariable: 'PORTAINER_USERNAME', passwordVariable: 'PORTAINER_PASSWORD')]) {
|
||||||
script {
|
script {
|
||||||
def response = httpRequest httpMode: 'POST',
|
// Create a JSON object for the authentication request
|
||||||
|
def authRequestBody = groovy.json.JsonOutput.toJson([
|
||||||
|
Username: PORTAINER_USERNAME,
|
||||||
|
Password: PORTAINER_PASSWORD
|
||||||
|
])
|
||||||
|
|
||||||
|
// Send the authentication request without logging sensitive data
|
||||||
|
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\":\"${PORTAINER_USERNAME}\",\"Password\":\"${PORTAINER_PASSWORD}\"}"
|
requestBody: authRequestBody,
|
||||||
|
consoleLogResponseBody: false // Prevent logging the response body
|
||||||
|
)
|
||||||
|
|
||||||
def json = readJSON text: response.content
|
def json = readJSON text: response.content
|
||||||
env.PORTAINER_TOKEN = json.jwt
|
env.PORTAINER_TOKEN = json.jwt
|
||||||
@ -32,11 +42,14 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deploy the stack on Portainer using the obtained token
|
// Deploy the stack on Portainer using the obtained token
|
||||||
httpRequest httpMode: 'PUT',
|
httpRequest(
|
||||||
|
httpMode: 'PUT',
|
||||||
customHeaders: [[name: 'Authorization', value: "Bearer ${env.PORTAINER_TOKEN}"]],
|
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}',
|
||||||
|
consoleLogResponseBody: false // Prevent logging the response body
|
||||||
|
)
|
||||||
|
|
||||||
echo 'Déploiement terminé.'
|
echo 'Déploiement terminé.'
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user