I'm having an issue when I try to execute a CURL command in one of the steps of a Jenkinsfile when it's working behind a proxy.
I'm working on Ubuntu 18 and I run the Jenkins container in like this:
docker run -d
-u root --privileged
-v jenkins_home:/var/jenkins_home
-v /var/run/docker.sock:/var/run/docker.sock
-v "$HOME":/home
-e JENKINS_OPTS="--prefix=/jenkins"
--group-add 997
-p 8080:8080
-p 50000:50000
--name jenkins
jenkinsci/blueocean
And then I have a simple Jenkinsfile
that clones the code from a git repository, makes an image, pushes it to a registry and finally sends a Telegram message using curl.
pipeline {
agent any
environment {
dockerImage = ''
}
stages {
stage('Testing') {
steps {
echo 'testing'
}
}
stage('Build image') {
steps {
script{
dockerImage = docker.build("registry.***.com.ar/hellonode")
}
}
}
stage('Push image') {
steps{
script {
docker.withRegistry('https://registry.***.com.ar', 'registryCredentials') {
dockerImage.push("${env.BUILD_NUMBER}")
dockerImage.push("latest")
}
}
}
}
stage('Push Notification') {
steps {
script{
withCredentials([string(credentialsId: 'telegramToken', variable: 'TOKEN'),
string(credentialsId: 'telegramChatId', variable: 'CHAT_ID')]) {
sh '''
curl -s -X \
POST https://api.telegram.org/bot${TOKEN}/sendMessage \
-d chat_id=${CHAT_ID} \
-d parse_mode="HTML" \
-d text="