Is there a way to get the last commit message without access to the repo? svn log --limit 1 tries to connect to the repo.
EDIT: I have credentials setup and using them to check out the source.
What I'm trying to achieve, is to get Jenkins triggering another job depending on the commit message, i.e. if it contains the string "#build" start job X. My attempt was to parse it in a Shell Build Step and execute a job depending on its outcome. But since I don't have anonymous access to the repo and don't want to embed credentials in the shell script, I have no idea how to achieve this.
Next would be git..
解决方案
This is what Jenkins Credentials plugin is for.
You configure credentials securely on Jenkins Global Configuration, and let the job reference that. No need to write anything in the script.
Edit:
To securely use a password from within a shell step
Under Jenkins Global Configuration, find Global Passwords section.
Add a name (this will be the environment variable name) and password (will be starred **** ).
Under Job Configuration, find Build Environment section.
Checkmark Inject passwords to the build as environment variables.
Then checkmark Global passwords.
In any build step, you can now use $name (as defined earlier) to refer to a password as you would if you were typing it in plain text.
The password variable is injected only at job execution time (typing $name on command line of the server by itself will not produce anything, and like all Jenkins variables, it is not persistent).
The job console log will show **** instead of password, if it appears.
You could configure passwords per job, rather than globally, so that other jobs can't use it.
The only security concern is that if someone has administrative permissions to configure your job, they can write echo $name > secretpassword.txt into a build step, and then review the file in the workspace. But you should be careful who you assign administrative rights to.