我有一个带文件共享的存储帐户(经典)设置。我使用“从Linux连接”(https://docs.microsoft.com/en-us/azure/storage/storage-file-how-to-use-files-portal#connect-to-file-share)中的信息,使用以下shell脚本将共享作为构建步骤挂载:
sudo apt-get -y update
echo Installing cifs-utils
sudo apt-get -y install cifs-utils
SHARE=$PWD/buildartifacts
echo Creating $SHARE
if [ ! -d $SHARE ]; then
sudo mkdir $SHARE
fi
echo Mounting $SHARE
sudo mount -t cifs $1 $SHARE -o vers=3.0,username=$2,password=$3,dir_mode=0777,file_mode=0777
我从VSTS版本传入共享路径,用户名和密码。
这是我从构建中获得的输出的尾部:
2017-07-12T11:56:01.0208730Z Creating config file /etc/samba/smb.conf with new version
2017-07-12T11:56:01.2016540Z Setting up libcap-ng0:amd64 (0.7.7-1) ...
2017-07-12T11:56:01.2433760Z Setting up libtalloc2:amd64 (2.1.5-2) ...
2017-07-12T11:56:01.2823630Z Setting up cifs-utils (2:6.4-1ubuntu1.1) ...
2017-07-12T11:56:01.3532550Z Setting up keyutils (1.5.9-8ubuntu1) ...
2017-07-12T11:56:01.4042470Z Setting up libtdb1:amd64 (1.3.8-2) ...
2017-07-12T11:56:01.4382800Z Setting up libtevent0:amd64 (0.9.28-0ubuntu0.16.04.1) ...
2017-07-12T11:56:01.4748150Z Setting up libldb1:amd64 (2:1.1.24-1ubuntu3) ...
2017-07-12T11:56:01.5114810Z Setting up python-crypto (2.6.1-6ubuntu0.16.04.2) ...
2017-07-12T11:56:01.9924790Z Setting up python-ldb (2:1.1.24-1ubuntu3) ...
2017-07-12T11:56:02.0912580Z Setting up python-tdb (1.3.8-2) ...
2017-07-12T11:56:02.1932370Z Setting up python-talloc (2.1.5-2) ...
2017-07-12T11:56:02.2329750Z Setting up samba-libs:amd64 (2:4.3.11+dfsg-0ubuntu0.16.04.8) ...
2017-07-12T11:56:02.2687050Z Setting up python-samba (2:4.3.11+dfsg-0ubuntu0.16.04.8) ...
2017-07-12T11:56:02.6471400Z Setting up samba-common-bin (2:4.3.11+dfsg-0ubuntu0.16.04.8) ...
2017-07-12T11:56:02.6860280Z Processing triggers for libc-bin (2.23-0ubuntu7) ...
2017-07-12T11:56:02.8437710Z Creating /opt/vsts/work/1/s/buildartifacts
2017-07-12T11:56:02.8522080Z Mounting /opt/vsts/work/1/s/buildartifacts
2017-07-12T11:56:02.8613570Z Unable to apply new capability set.
2017-07-12T11:56:02.8828840Z ##[error]/bin/bash failed with return code: 2
2017-07-12T11:56:02.8873290Z ##[error]Bash failed with error: /bin/bash failed with return code: 2
2017-07-12T11:56:02.9474600Z ##[section]Finishing: Shell Script setup-hosted.sh
我已经成功地使用了我使用的Windows Hosted Agent:
net use <share> /u:AZURE\<username> <password>
这里的不同之处在于我然后访问了没有驱动器号的文件目录:
/路径/到/文件 似乎Hosted Linux Agent for VSTS未配置为允许挂载cifs共享。这是正确的和预期的行为吗?
返回的VM功能集:
sudo capsh --print
输出:
Current: = cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_mknod,cap_audit_write,cap_setfcap+eip
Bounding set =cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_mknod,cap_audit_write,cap_setfcap
Securebits: 00/0x0/1'b0
secure-noroot: no (unlocked)
secure-no-suid-fixup: no (unlocked)
secure-keep-caps: no (unlocked)
uid=0(root)
gid=0(root)
groups=0(root)
根据功能(7)手册页:
CAP_SYS_ADMIN
* Perform a range of system administration operations including: quotactl(2), mount(2), umount(2), swapon(2), swapoff(2), sethostname(2), and setdomainname(2);
和从山(2):
Appropriate privilege (Linux: the CAP_SYS_ADMIN capability) is required to mount filesystems.
答案 0 :(得分:2)
“托管Linux预览版”池的代理实际上是在容器内部运行,看起来在容器内运行时安装该文件系统需要特殊功能。
很快就计划在VSTS上与Docker和容器进行更深入的集成,这将导致“托管Linux预览”池的工作方式发生变化。
在此之前,一个(略微hacky)解决方法可能涉及启动具有正确功能的第二个容器(主机的docker守护程序安装在代理运行的容器内)以将驱动器安装在共享文件夹中使用当前代理容器。
答案 1 :(得分:0)
Linux SMB3客户端尚不支持共享级加密,所以 在Linux中挂载文件共享仅适用于虚拟机 在与文件共享相同的Azure区域中运行。
转到VSTS的设置页面并检查区域(https://[account].visualstudio.com/_admin/_home/settings
),然后与您的存储区域进行比较。