E-mail : support@tech2now.in

How to configure proxy in jenkins file

Jenkins

Sample script to use the proxy in jenkins file.

pipeline {
agent any

environment {

// Define proxy environment variables
proxyHost = ‘proxy.example.com’
proxyPort = ‘8080’
// Add any additional proxy-related environment variables if required
}

stages {
stage(‘Build’) {
steps {
// Set proxy environment variables
script {
sh “export http_proxy=http://${env.proxyHost}:${env.proxyPort}”
sh “export https_proxy=http://${env.proxyHost}:${env.proxyPort}”
// Add any additional proxy-related environment variables if required
}

// Run your build steps or commands here
// For example:
sh ‘mvn clean install’
}
}
}
}