adarsh hota
adarsh hota

Reputation: 327

How to display jenkins default environment variable from shell command?

I am not able to get output of the Environment-Variable BUILD_URL through Shell command.

Configured Manage Jenkins-->Configure System-->Jenkins Location-->Jenkins URL as http://xxx.xxx.xxx.xxx:8080/

Using below script within Shell command.

#!/bin/bash

echo ${BUILD_URL}

Do i have to set jenkins_url within the script?

Upvotes: 0

Views: 2358

Answers (1)

Dvir669
Dvir669

Reputation: 8670

In a Shell you can't access environment variables like that. you will need to read here: https://www.digitalocean.com/community/tutorials/how-to-read-and-set-environmental-and-shell-variables-on-a-linux-vps.

What you can do is in the Jenkins's job session you can send a parameter to your script to gain access to the env parameter. in the Shell section you will have access to the environment parameter, in the script itself it'll work differently.

Good luck

Upvotes: 1

Related Questions