- Write a property file: /home/bvt/docs/jenkinsEnv.properties:
gcp.job.type=deliver gcp.deliver.ip=10.0.7.142 gcp.deliver.user=gcp gcp.deliver.home=/home/gcp gcp.deliver.deployFolder=deploy gcp.deliver.prompt=gcp@cloud142
Note: Do not leave blanks between "=" and values in property file.
gcp.deliver.home = /home/gcp
will produce wrong value when gotten by expect script.
-
Add this file to "Build Environment -> Inject environment variables to the build process" in Jenkins Job Configure panel with Environment Injector plugin.
-
Create a deploy script (deploy.exp) in project base folder:
#!/usr/bin/expect set artifact [lindex \(argv 0] spawn scp $artifact $env(gcp.deliver.user)@\)env(gcp.deliver.ip):$env(gcp.del expect eof
- Create a "Conditional step(single)" with conditional-buildstep plugin.
Run? Strings match
String 1: ${ENV,var="gcp.job.type"}
String 2: deliver
Builder: Execute Shell
Command: ./deploy.exp build/*.zip