Closed dev4dev closed 3 years ago
@dev4dev, I see you did somes improvements to your feature a week ago wich I like to see in this PR :) Can you explained what you added exactly?
@mat1e Hi, to explain all that noise I just describe what I'm doing
I'm using Ansible to set up a mac node and a user on it, and then I want all clones, which are made by this plugin, to have the same configuration. My changes add the ability to copy all the stuff from the initial user's directory ~/.ssh
to every new user, thus I'll have all env vars and ssh keys available for each build
@dev4dev, please check the version 1.3.0 of the plugin, I think you can do what you're looking for.
@mat1e thanks, I would need to find a time to check this out. As an intermediate stage, I ended up with this solution
I think it is too specific to merge this into the whole project, or maybe those features should be implemented in a more generic way.
Basically, that allows copying some predefined stuff (environment) from ~/.ssh
directory, and copy .netrc
file with creds for git directly from Jenkins master.
I'm just an iOS Developer, and this was a hobby to move our builds from Travis to an in-house solution. This works now. We can try to think about how this can be beneficial for the plugin. Or maybe you can give a hint on how I can achieve the same result using that new feature from 1.3.0
Cheers
@dev4dev, effectively your solution is too specific. But, it is possible to do it by another way. With the new feature in 1.3.0, you can run the command to copy your ~/.ssh directory directly by using "Pre-launch commands" field.
For netrc file, what you do actually allow all users on Jenkins to use credentials in the netrc file. Just by building their jobs using the Mac label.
For another solution, you will require the folders plugin, credentials plugin and to improve the security of your password, the mask-passwords plugin.
After these plugins installed on your Jenkins, you can create credentials in the folder of your job. Like this only jobs into the folder can access to it.
Then, at the top of your pipeline, you can do something like :
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'your_credentials_id', passwordVariable: 'PWD_DATA', usernameVariable: 'USER_LOGIN']]) {
sh "echo 'machine your_machine login $USER_LOGIN password $PWD_DATA' > ~/.netrc"
}
Here is a useful feature to allow copy predefined file with environment vars from the source user to every new agent
Basically, it copies file
~/.ssh/environment
to new user/Users/<agent>/.ssh/environment
This can be configured from Mac Cloud set preferences page