Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to install AWS CLI on VSTS Hosted Linux agent ? #15

Open
samuelneff opened this issue Sep 11, 2017 · 10 comments

Comments

Projects
None yet
@samuelneff
Copy link

commented Sep 11, 2017

I'm trying to run the AWS CLI on a VSTS hosted linux agent and following the instructions from here:

http://docs.aws.amazon.com/cli/latest/userguide/awscli-install-linux.html

  • Download PIP
  • Install PIP
  • Use PIP to install AWS CLI

Seems simple enough and using the Command Line task in my VSTS release I was able to download and install PIP, but the very next command that attempts to use it fails:

##[error]Failed which: Not found pip: null
##[error]undefined failed with error: Failed which: Not found pip: null

Full logs below. What am I doing wrong?

Thanks,

Sam

##[section]Starting: Download PIP
==============================================================================
Task         : Command Line
==============================================================================
[command]/usr/bin/curl -O https://bootstrap.pypa.io/get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 1558k  100 1558k    0     0  1884k      0 --:--:-- --:--:-- --:--:-- 1886k
##[section]Finishing: Download PIP
##[section]Starting: Install PIP
==============================================================================
Task         : Command Line
==============================================================================
[command]/usr/bin/python get-pip.py --user
Collecting pip
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
Collecting setuptools
  Downloading setuptools-36.4.0-py2.py3-none-any.whl (478kB)
Collecting wheel
  Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.1 setuptools-36.4.0 wheel-0.30.0
##[section]Finishing: Install PIP
##[section]Starting: Install AWS CLI
==============================================================================
Task         : Command Line
==============================================================================
##[error]Failed which: Not found pip: null
##[error]undefined failed with error: Failed which: Not found pip: null
##[section]Finishing: Install AWS CLI
##[section]Finishing: Release
@incarnate

This comment has been minimized.

Copy link

commented Sep 12, 2017

VSTS runs every task in a fresh session, so changes to the PATH don't persist between tasks. To work around that, you can do a global install instead.

I tested using the below in the Shell++ task that comes with Release Management Utility tasks:

echo 'Installing AWS'
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
pip --version
pip install awscli --upgrade
aws --version

@steveataws steveataws added the question label Oct 11, 2017

@Rabadash8820

This comment has been minimized.

Copy link

commented May 23, 2018

@incarnate I tried using that exact same sequence of commands in a Shell++ task like you suggested, but unfortunately I'm getting the following error: D:\a\1\s/user_script.sh: /c/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/Scripts/aws: c:\program: bad interpreter: No such file or directory. It looks to me like these commands don't put aws on the PATH either, or am I just missing something?

@renanlq

This comment has been minimized.

Copy link

commented Jul 17, 2018

Thanks @incarnate , here works with Command Line Task to our VSTS Linux Agent, even in preview.
Best regards.

@joaoasrosa

This comment has been minimized.

Copy link

commented Oct 19, 2018

For the new versions needs to be something like:

echo 'Installing AWS'
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py --user
export PATH="/home/vsts/.local/bin:$PATH"
pip --version
pip install awscli --upgrade --user
aws --version
@JCH01

This comment has been minimized.

Copy link

commented Jan 25, 2019

Since the VSTS "Hosted Linux Preview" is going away, I tried switching to "Hosted Ubuntu 1604", tried the script above. The aws version shows correctly, indicating awscli was installed correctly. Still the "AWS CLI Task" that we run afterwards fails with "AWS CLI is not installed on this machine"

@JCH01

This comment has been minimized.

Copy link

commented Jan 30, 2019

In case somebody gets here with the same question... I went back to my original script, adding "sudo" on the install commands and now everything works as before on "Hosted Ubuntu 1604". So this is working for me:

echo "Installing AWS CLI =========================================="
which python
pip --version
sudo pip install setuptools
sudo pip install wheel
sudo pip install awscli --upgrade
aws --version

[https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azdevops&tabs=yaml]
"If you have scripts that assume that they're running as root, then you'll need to change them to use sudo."

@ross-bohr

This comment has been minimized.

Copy link

commented Apr 4, 2019

Could be simplified to :

sudo pip3 install --upgrade pip
pip3 install awscli --upgrade --user

Works on Hosted Ubuntu 1604

@pedroswat

This comment has been minimized.

Copy link

commented Apr 15, 2019

@ross-bohr This works on Hosted Ubuntu 1604. Your command was missing the export:

sudo pip3 install --upgrade pip
pip3 install awscli --upgrade --user
export PATH="/home/vsts/.local/bin:$PATH"
aws --version

Despite the installation of AWS CLI on the Bash step, the AWS CLI step sill fails with AWS CLI is not installed on this machine.
Don't know whats missing.

Captura de ecrã 2019-04-15, às 14 35 30

@justnance justnance added guidance and removed question labels Apr 20, 2019

@Zebirdman

This comment has been minimized.

Copy link

commented May 15, 2019

i installed the aws cli using the same methods described above, i was able to access the aws command in subsequent scripts by running the export PATH="/home/vsts/.local/bin:$PATH" command again at the start. As stated by @incarnate changes to the path do not persist between tasks.

@pedroswat

This comment has been minimized.

Copy link

commented May 15, 2019

So basically, we have to install AWS CLI in each step.
This is my setup for releasing for AWS ECS:

yolo

Thanks all for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.