You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
When building, testing, and deploying an application with TeamCity, you may need to run a build under a specific user account, different from the one used to run the build agent.
4
4
5
-
The teamcity-runas plugin can be used to run TeamCity build steps under a specified user account on Windows or Linux. See [Wiki](https://github.com/JetBrains/teamcity-runas-plugin/wiki) for more information:
5
+
The teamcity-runas plugin can be used to run TeamCity build steps under a specified user account on Windows, Mac or Linux. See [Wiki](https://github.com/JetBrains/teamcity-runas-plugin/wiki) for more information:
6
6
7
7
*[How to Install](https://github.com/JetBrains/teamcity-runas-plugin/wiki/How-to-install)
echo"##teamcity[message text='User \"$args\" has no required permissions for target directory|n \"$TMPDIR\".|n Make sure this user has permissions to write and to execute files in the target directory (rwx)|n and to search (X) in all its parent directories' status='ERROR']"
49
+
exit 255
50
+
fi
51
+
52
+
# check that agent won't be able to remove temporary files created by the build step
53
+
rm "$tmpFile"&>/dev/null
54
+
55
+
if [ -f"$tmpFile" ];then
56
+
rm "$tmpScriptFile"&>/dev/null
57
+
echo##teamcity[message text='Incorrect runAs configuration: agent won't be able to remove temporary files created by the build step, see teamcity-agent.log for details .' status='ERROR']
echo"##teamcity[message text='socat was not installed, see https://github.com/JetBrains/teamcity-runas-plugin/wiki/How-to-install#teamcity-agent-on-linux' status='ERROR']"
86
+
exit 255
87
+
fi
88
+
89
+
args="$2"
90
+
command="$3"
91
+
password="$4"
92
+
93
+
tmpFile=$(mktemp "$TMPDIR"/XXXXXXXX)
94
+
touch "$tmpFile"
95
+
chmod a+rw "$tmpFile"
96
+
97
+
cmd="'${0}' su '$tmpFile' '$command' '$args' arg5"
98
+
eval"export -- SOCAT_CMD=\"$cmd\""
99
+
100
+
# run command
101
+
(
102
+
# wait for password input
103
+
attempts=50
104
+
while [[ !-s"$tmpFile"|| attemps -gt 0 ]];
105
+
do
106
+
sleep .1
107
+
attempts=$((attempts-1))
108
+
done
109
+
110
+
if [[ $attempts-eq 0 ]];
111
+
then
112
+
echo"##teamcity[message text='Error during sending password' status='ERROR']"
113
+
exit 255
114
+
fi
115
+
116
+
# send password to su stdIn
117
+
echo"$password"
118
+
119
+
# wait for process finish
120
+
while ps axg | grep "$tmpFile"| grep -v "grep"> /dev/null;
0 commit comments