Hi.

I'm trying to migrate from a freestyle job to a pipeline that has three 
stages (build, test and deploy)
In the deploy stage, I'd like to rsync files to a remote server.

In my freestyle job, I used to inject environment variables to the build 
process, by specifying them in the properties content textarea like so:

SSHUSERNAME=foo
SSHSERVER=178178.178.178
REMOTEPATH='/var/virtual_www/htdocs';

That meant that I could then always use the same deploy script, that would 
use those variables, no matter the project:

rsync -uvr --delete --exclude-from $WORKSPACE/CI/exclude-file.txt $WORKSPACE/* 
$SSHUSERNAME@$SSHSERVER:$REMOTEPATH;


Now regarding pipeline scripts.
How could I implement something equivalent in pipelines per branch? 
As this is sensitive data, I do not see myself declaring variables inside a 
script that is committed to a repo, so writing them inside the Jenkins File 
seems out of order.
And that would also mean changing the deploy script for each client, which 
I'd like to avoid.

I've been told to look into credentials, but from what I understood (I'm 
really not a Jenkins expert, I'm trying to learn), credentials seem to be 
global key / value pairs ?
Is there a way to create credentials that are only within the project 
scope? Or are they only global?
If they are global? Does that mean that I need to create one credential for 
each line I've just shown as example? And that I also need to change the 
name for each branch, and for each branch per project? Like 
project1_master_sshuser, project1_develop_sshuser?
Doesn't that seem a bit cumbersome?
Or maybe I need to use a secret file to put all those information in?

Well as you can see this part is still a bit obscure for me :)

Any help on implementing this would be hugely appreciated.
I've arleady planned to write a blog post about the entire setup to spread 
the help.


TL;DR
- I'm trying to migrate from a freestyle job to a pipeline
- In my freestyle job, I used to inject environment variables to the build 
process, by specifying them in the properties content textarea
- How could I inject environment variables in pipelines per branch?  


Thanking you.
Regards.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/55fb1b40-e6ab-455c-b93b-7de6d6b0c7ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to