How to set Environment Variables on EC2 instance via User Data

前端 未结 9 745
北荒
北荒 2020-12-14 07:34

I am trying to set environment variables with EC2s user data, but nothing i do seems to work

here are the User data scripts i tried

#!/b         


        
9条回答
  •  清歌不尽
    2020-12-14 08:17

    Adding this to the init script of the node will add environment variables on launch. They won't show up in the node configuration page but they will be able to use in any job.

    #!/bin/bash
    echo 'JAVA_HOME="/usr/lib/jvm/java-8-oracle/"' | sudo tee -a /etc/profile#
    

    This answer is similar to what hamx0r proposed however, jenkins doesn't have permission to echo to /etc/profiles with or without sudo.

提交回复
热议问题