Re: Sourcing environment variables on node
Thanks ichymuzzle. It worked with a minor change. So the problem is that each sh looses it's environment. Is there a way to set it globally? node ('remote-server') { sh (''' . /home/cmr/myenv echo "My Variables: $FOO $BAR" ''') } On Thursday, 2 November 2017 14:01:04 UTC-5, itchymuzzle wrote: > > Maybe something like this? > > node ('remote-server') { > sh ''' >. /home/cmr/myenv' >echo "My Variables: ${env.FOO} ${env.BAR}" > ''' > } > -- 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/892167f5-00f0-43be-ac79-20eb6dec8bfd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Sourcing environment variables on node
Hi all, on a remote node I have a file that exports some variables: $ cat myenv export FOO=Hello export BAR=World My pipeline script tries to source that file, but the variables don't seem to stick: node ('remote-server') { sh ('. /home/cmr/myenv') echo "My Variables: ${env.FOO} ${env.BAR}" } Output: [set-remote-env] Running shell script + . /home/cmr/myenv ++ export FOO=Hello ++ FOO=Hello ++ export BAR=World ++ BAR=World[Pipeline] echoMy Variables: null null When I source directly from the server's command prompt, the variables stick: $ . myenv $ echo "My Variables: $FOO $BAR" My Variables: Hello World $ How can I source environment variables in my pipeline script? Thanks! -- 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/2bfd3d27-2fe7-4e49-9e9c-a7edaf416e60%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Best way to develop pipeline groovy
Thanks Daniel, when making changes in replay, is there a way to promote those changes to the actual script, or would I have to copy them? Will the Jenkins CLI work only for declarative pipeline syntax, or will scripts work, too? Cheers, C On Wednesday, 1 November 2017 08:02:12 UTC-5, Daniel Beck wrote: > > > > On 31. Oct 2017, at 22:51, Christoph Ruepprich <cruep...@gmail.com > > wrote: > > > > This gets pretty tedious and time consuming. Is there a better way to > develop scripts without having to either develop them in the web UI or copy > & paste them? > > https://jenkins.io/blog/2016/04/14/replay-with-pipeline might also help. > > The declarative pipeline syntax also has a linter accessible from the > Jenkins CLI, which should cut down on the trial & error executions: > https://jenkins.io/doc/book/pipeline/development/#linter > > -- 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/30c0e3a4-aece-4398-9351-fe21d0f886bd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Best way to develop pipeline groovy
Thanks Alex, I think the replay is probably the better option for me. C On Tuesday, 31 October 2017 17:05:14 UTC-5, slide wrote: > > There are two things that might make your life easier: > > 1) Jenkinsfile, you can put this into your source control and then it will > be executed as if it were in the web ui. You just change the option in the > job setup to "Pipeline script from SCM" instead of "Pipeline script". Then > when you push updates to the Jenkinsfile, it will use your changes. > 2) The Replay. This allows you to rerun a pipeline job and make small > modifications to the script that was used to test things out, then you can > incorporate those changes into your Jenkinsfile. > > Hope those things help > > Alex > > On Tue, Oct 31, 2017 at 2:51 PM Christoph Ruepprich <cruep...@gmail.com > > wrote: > >> I'm new to Jenkins and am learning how to write groovy scripts for >> pipelines. Right now I write my code in VS Code and copy & paste it into >> the Jenkins' project, save and build. This gets pretty tedious and time >> consuming. Is there a better way to develop scripts without having to >> either develop them in the web UI or copy & paste them? >> >> Thanks! >> >> -- >> 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-use...@googlegroups.com . >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jenkinsci-users/a2f17740-5fec-4b9b-977c-df877bdf0fbc%40googlegroups.com >> >> <https://groups.google.com/d/msgid/jenkinsci-users/a2f17740-5fec-4b9b-977c-df877bdf0fbc%40googlegroups.com?utm_medium=email_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- 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/6597d092-96dc-49a7-8710-7c8a148ccfd4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Best way to develop pipeline groovy
I'm new to Jenkins and am learning how to write groovy scripts for pipelines. Right now I write my code in VS Code and copy & paste it into the Jenkins' project, save and build. This gets pretty tedious and time consuming. Is there a better way to develop scripts without having to either develop them in the web UI or copy & paste them? Thanks! -- 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/a2f17740-5fec-4b9b-977c-df877bdf0fbc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Newbie question: pipeline {} vs node {}
Thanks Robert, it helps a lot just knowing what the two different systems are called (declarative vs. scripted). Cheers, C On Tuesday, 31 October 2017 09:53:58 UTC-5, Robert Hales wrote: > > There are 2 different syntaxes. Declarative is the pipeline{} style. > scripted doesn't necessarily start with node{}, but uses that heavily. > > Scripted syntax is basically a straight groovy code DSL. Use it when you > need to do more complex and interesting things and aren't afraid to get > down into writing code. > > Declarative syntax is a more friendly and easy-to-learn syntax. It can be > intermingled with scripted in many ways, so I usually like to start with a > declarative pipeline and as things start to get more complex where I have > had to use too many script{} block or other straight groovy, then I'll > consider scraping the declarative framework and converting to a straight > groovy script. > > > On Tuesday, October 31, 2017 at 8:37:24 AM UTC-6, Christoph Ruepprich > wrote: >> >> Looking at some pipeline scripting examples, I see that there are two >> different ways to script a pipeline. One begins with pipeline {} the other >> with node {}. What is the difference between the two, and when would I use >> one or the other? >> >> thanks, >> C >> > -- 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/8d7ff6d1-0205-4e99-9c75-9613289f11d9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Newbie question: pipeline {} vs node {}
Looking at some pipeline scripting examples, I see that there are two different ways to script a pipeline. One begins with pipeline {} the other with node {}. What is the difference between the two, and when would I use one or the other? thanks, C -- 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/43f5428f-25b4-4e4f-994a-427fb1c8849f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.