How to Set A Proxy In the Jenkins Pipeline?

7 minutes read

To set a proxy in the Jenkins pipeline, you can follow the steps below:

  1. Open your Jenkins pipeline script or Jenkinsfile.
  2. Define the proxy settings at the start of the pipeline script by adding the following lines:
node {
   // Set proxy environment variables
   withEnv(["http_proxy=", "https_proxy="]) {
      // Your pipeline steps here

Make sure to replace with the actual proxy server and port you want to use.

  1. Inside the withEnv block, you can include all the pipeline steps that you want to execute while using the proxy settings.
  2. Save the pipeline script.

By setting the http_proxy and https_proxy environment variables using the withEnv block, Jenkins will use the specified proxy server for all HTTP and HTTPS connections made during the execution of the pipeline steps.

Best Proxy Server Providers of 2024


Rating is 5 out of 5



Rating is 4.9 out of 5



Rating is 4.8 out of 5


Rating is 4.7 out of 5


How to set a proxy for Jenkins pipeline on Windows?

To set a proxy for Jenkins pipeline on Windows, you can follow these steps:

  1. Open the Jenkins web interface in your browser by visiting http://localhost:8080.
  2. Click on "Manage Jenkins" on the left-hand side menu.
  3. In the Manage Jenkins page, click on "Manage Plugins".
  4. Go to the "Advanced" tab and scroll down to the "HTTP Proxy Configuration" section.
  5. Enable the "Use proxy" checkbox.
  6. Enter the proxy server address and port in the respective fields. For example, if the proxy server address is and the port is 8080, enter
  7. If your proxy server requires authentication, enable the "Use proxy authentication" checkbox. Enter the username and password credentials in the respective fields.
  8. Click on the "Test Proxy Configuration" button to verify if the proxy settings are correct.
  9. Click on "Apply" and then "Save" to save the changes.

After setting up the proxy configuration in Jenkins, your pipeline jobs will use the configured proxy settings for any external network connections.

What are the potential issues with proxy configuration in Jenkins pipelines?

There are several potential issues with proxy configuration in Jenkins pipelines:

  1. Proxy Authentication: If the proxy server requires authentication, the pipeline may fail if the credentials are not provided correctly or if there are issues with the authentication mechanism.
  2. Proxy Settings: Incorrect or missing proxy settings in the Jenkins configuration can result in the pipeline not being able to reach external resources through the proxy server.
  3. Network Connectivity: Network connectivity issues between Jenkins and the proxy server can cause the pipeline to fail. This could be due to firewall rules, network configuration problems, or other network-related issues.
  4. Proxy Server Stability: If the proxy server is not stable or experiences downtime, it can disrupt the pipeline's ability to access external resources. This can lead to pipeline failures or delays.
  5. SSL/TLS Certificates: If the proxy server uses SSL/TLS encryption, the pipeline may encounter issues with certificate validation. Misconfigured or expired certificates can cause SSL handshake failures and prevent the pipeline from establishing a secure connection.
  6. Proxy Server Performance: If the proxy server is overloaded or has limited capacity, it can result in slow network access for the pipeline. This can impact the overall pipeline performance and cause delays.
  7. Proxy Bypass Rules: Incorrectly configured proxy bypass rules can lead to unexpected behavior in the pipeline. If certain resources are excluded from proxy usage but should not be, or vice versa, it can result in issues with accessing those resources.
  8. Environment Variables: Incorrectly set or missing environment variables related to proxy configuration can cause problems. It is important to ensure that the necessary environment variables are correctly set within the pipeline.

To mitigate these issues, it is advisable to carefully configure proxy settings in Jenkins, test connectivity and authentication, and have proper monitoring and alerting in place to identify and address any potential problems.

How to set a proxy in the Jenkins pipeline?

To set a proxy in the Jenkins pipeline, you can use the withEnv step to set the necessary environment variables. Here's an example of how you can set the proxy:

pipeline {
    agent any

    environment {
        http_proxy = ""    // Replace with your proxy URL
        https_proxy = ""   // Replace with your proxy URL
        no_proxy = "localhost,"                // Replace with your exceptions (if any)

    stages {
        stage('Build') {
            steps {
                // Your build steps here
                // The proxy configurations will be used for these steps

Make sure to replace the proxy URL with the correct address of your proxy server. Additionally, you can add any exceptions to the no_proxy variable if needed.

Note that setting the proxy environment variables will only affect the steps within the stage block. If you have multiple stages in your pipeline, you may need to repeat the environment block for each stage where the proxy configuration is required.

What is the difference between a forward proxy and a reverse proxy?

A forward proxy and a reverse proxy serve different purposes in a network.

Forward Proxy:

  • A forward proxy acts as an intermediary between a client (usually a user or a device) and a server.
  • When a client makes a request to access a web resource, the request is first sent to the forward proxy server.
  • The forward proxy server then forwards the request to the internet on behalf of the client.
  • It can be used to add an extra layer of security, filter and block certain content, cache data, or anonymize the client's IP address.
  • The client is generally unaware of the forward proxy's existence.

Reverse Proxy:

  • A reverse proxy, on the other hand, acts as an intermediary between the internet and servers in a private network.
  • When a client makes a request to access a web resource, the request is first sent to the reverse proxy server.
  • The reverse proxy server then forwards the request to the appropriate server within the private network that can fulfill the request.
  • It helps distribute incoming requests across multiple servers to balance the load and ensure better performance and availability.
  • It can also provide additional security measures such as SSL encryption, caching, or acting as a firewall to protect the servers in the private network.
  • The client is generally aware of the reverse proxy's existence as it directly communicates with it to access the resources.
Facebook Twitter LinkedIn Telegram Whatsapp Pocket

Related Posts:

To install Jenkins in Ubuntu, you can follow these steps:Open the terminal on your Ubuntu machine. Update the package list by running the command: sudo apt update Install Java Development Kit (JDK) using the command: sudo apt install default-jdk Add the Jenkin...
To use a proxy in Selenium Python, you can follow the steps mentioned below:Import the necessary modules: from selenium import webdriver from selenium.webdriver.common.proxy import Proxy, ProxyType Set up the proxy: proxy = Proxy() proxy.proxy_type = ProxyType...
To run Jenkins behind Nginx, you need to follow the steps below:Installing and configuring Nginx: Install Nginx on your server. Open the Nginx configuration file, usually located at /etc/nginx/nginx.conf. Add a new server block inside the http block to define ...
To set a proxy in Java code, you can use the package to configure the proxy settings. Here's how you can do it:First, create a Proxy object by specifying the type of proxy you want to use. Java supports several proxy types, such as HTTP, HTTPS, SO...
To get a proxy for WhatsApp, you need to follow these steps:Research and choose a reliable proxy service provider: Look for a trustworthy proxy service provider that offers servers in the location you desire. Subscribe to a proxy service: Sign up for a proxy s...
To set a proxy for curl, you can use the following command line options:curl --proxy :: Replace with the IP address or hostname of the proxy server, and with the port number on which the proxy server is listening. curl --proxy-user :: If your proxy server re...