Re: Build Docker Image from a Dockerized Jenkins

2017-12-03 Thread Jeeva Chelladhurai
>
> I have not tried this, so, cannot vouch for this. Please be cautious about
> the approach presented in this blog.
>
> http://niels.nu/blog/2017/continuous-blog-delivery-p2.html : you might be
> interested in Docker-in-Docker.
>
>
> Thanks for the suggestion.. Docker-in-Docker is been discouraged here is
good read on it
https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/

- Jeeva

-- 
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/CAK5CbZXcvHWevqGmjPTXkAhU5MRNuHk6LOg6iEYrMwdNyb-abA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Translation between declaritive pipleline and groovy pipeline

2017-12-03 Thread Ramanathan Muthaiah

>
> What would be the equivalent of this:
>
> post {
> always {
> echo 'One way or another, I have finished'
> deleteDir() /* clean up our workspace */
> }
> success {
> echo 'I succeeeded!'
> }
> unstable {
> echo 'I am unstable :/'
> }
> failure {
> echo 'I failed :('
> }
> changed {
> echo 'Things were different before...'
> }
> }
> }
>
> in a Groovy pipleline? 
>
> I'm looking at using "something" to notify by email if a build fails
>
>
Groovy code presented in this Cloudbees' article is about mail 
notifications (also, slack and hipchat) -- but you may want to extend it to 
suit your needs.

https://www.cloudbees.com/blog/sending-notifications-pipeline

/Ram

-- 
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/da5927cf-2fc5-4c46-9734-8db06b87be7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Build Docker Image from a Dockerized Jenkins

2017-12-03 Thread Ramanathan Muthaiah
Hi Jeeva,
 

> I would like to build Docker images from a Dockerized Jenkins. There are 
> multiple solution out there but what is the recommended solution...
>
> I have been using ssh node as a work around, but I was told to use 
> https://wiki.jenkins.io/display/JENKINS/Docker+Slaves+Plugin . In order 
> for this plugin to work, I have to install docker inside the Jenkins (my 
> docker host is RHEL) and also mount the /var/run/docker.sock or enable 
> TLS. Isn't installing docker blow up the size of the Jenkins image? 
>
> Any way to install just the docker client in side the Jenkins image? 
>

I have not tried this, so, cannot vouch for this. Please be cautious about 
the approach presented in this blog.

http://niels.nu/blog/2017/continuous-blog-delivery-p2.html : you might be 
interested in Docker-in-Docker.

/Ram 

-- 
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/e973fe60-490e-476c-9efb-de2aa5a2e09c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Build Docker Image from a Dockerized Jenkins

2017-12-03 Thread Jeeva Chelladhurai
Hi Nicolas,

Thanks for your input. Using Java API is an excellent idea. There is
hackathon planned for Jenkins this week
https://www.meetup.com/jenkinsBLR/events/240212894/
Perhaps, this requirement could be prioritized at the hackathon if you
could give a helping hand..

Thanks,
Jeeva

On Mon, Dec 4, 2017 at 12:48 AM, nicolas de loof 
wrote:

> There's no "recommended" solution, each plugin comes with it's own vision,
> benefits and drawbacks.
>
> docker-plugin can be used to run dockerized agents, it can run from a
> dockerized jenkins master with /var/run/docker.sock without docker CLI
> installed, as it uses a java client library for docker API.
> docker-slaves-plugin do rely on running docker CLI executed from master, I
> planned to use a java API at some point but still need to work on this. In
> the meantime I don't think there's a simple way to just install docker CLI.
> Installing full docker will make your image a bit bigger with additional
> files on filesystem but there won't be any extra process running, so not a
> major issue (considering jenkins docker image is already a big one)
>
> 2017-12-03 18:42 GMT+01:00 Jeeva Chelladhurai :
>
>> Hello All,
>>
>> I would like to build Docker images from a Dockerized Jenkins. There are
>> multiple solution out there but what is the recommended solution...
>>
>> I have been using ssh node as a work around, but I was told to use
>> https://wiki.jenkins.io/display/JENKINS/Docker+Slaves+Plugin . In order
>> for this plugin to work, I have to install docker inside the Jenkins (my
>> docker host is RHEL) and also mount the /var/run/docker.sock or enable
>> TLS. Isn't installing docker blow up the size of the Jenkins image?
>>
>> Any way to install just the docker client in side the Jenkins image?
>>
>> Thanks,
>> Jeeva
>>
>> --
>> Jeeva K S Chelladhurai
>>
>> --
>> 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/ms
>> gid/jenkinsci-users/CAK5CbZV3Sc-fgYS_34PgEwRzsF20%3Dp6mbaagb
>> R2Ehtz01op2%3Dw%40mail.gmail.com
>> 
>> .
>> 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/CANMVJzk7GJDmKUKQNvt4PzLpXHtTp
> %2B7BnikYfeysX7_kdpxcUA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jeeva K S Chelladhurai

-- 
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/CAK5CbZUpZCQDctutTX9BwouEkT7Jnf%2BOLzXejpqFHKkK_ON%3DLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Translation between declaritive pipleline and groovy pipeline

2017-12-03 Thread Peter Berghold
What would be the equivalent of this:

post {
always {
echo 'One way or another, I have finished'
deleteDir() /* clean up our workspace */
}
success {
echo 'I succeeeded!'
}
unstable {
echo 'I am unstable :/'
}
failure {
echo 'I failed :('
}
changed {
echo 'Things were different before...'
}
}
}

in a Groovy pipleline?

I'm looking at using "something" to notify by email if a build fails

-- 
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/CAArvnv1EH79K8XA9QMUDTqRAa8QWsixi_Pdx7cYon-88nyjcKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Build Docker Image from a Dockerized Jenkins

2017-12-03 Thread Jacob Larsen
I wouldn't use Docker Slaves for this. Just install the docker client in 
your Jenkins image and bind mount /var/run/docker.sock. Then a simple sh 
step with docker build + docker push should do the trick.


If you don't want to use your jenkins master for this, you could make a 
slave container with these tools and bind mount.


The Docker Slaves plugin is more about running your builds in containers 
than it is about building images.


/Jacob


On 2017-12-03 18:42, Jeeva Chelladhurai wrote:

Hello All,

I would like to build Docker images from a Dockerized Jenkins. There 
are multiple solution out there but what is the recommended solution...


I have been using ssh node as a work around, but I was told to use 
https://wiki.jenkins.io/display/JENKINS/Docker+Slaves+Plugin . In 
order for this plugin to work, I have to install docker inside the 
Jenkins (my docker host is RHEL) and also mount the 
/var/run/docker.sock or enable TLS. Isn't installing docker blow up 
the size of the Jenkins image?


Any way to install just the docker client in side the Jenkins image?

Thanks,
Jeeva

--
Jeeva K S Chelladhurai

--
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/CAK5CbZV3Sc-fgYS_34PgEwRzsF20%3Dp6mbaagbR2Ehtz01op2%3Dw%40mail.gmail.com 
.

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/2162124b-1539-acc7-e92c-56ac5674aa7c%40larsen.net.
For more options, visit https://groups.google.com/d/optout.


RE: How can I inject environment variables into my groovy class?

2017-12-03 Thread Daniel Butler
If you’re dealing with a stubborn library that’s forcing you to use environment 
variables to pass in parameters you’re in for more pain than it’s worth trying 
to run it within the pipeline script environment.

Use it by running a groovy script externally, e.g.

sh “groovy MyScript.groovy”

and then you’ve got all the environment variables setup and you’re in a 
standard groovy environment without the pipeline restrictions and 
idiosyncrasies.



From: red 888
Sent: 03 December 2017 00:28
To: Jenkins Users
Subject: Re: How can I inject environment variables into my groovy class?

"In the pipeline there’s the global variable `env` which is a map of all the 
currently declared environment variables (JOB_NAME etc) you could pass into 
your class."

Is there a way to do that so all those envs are imported and accessible in the 
class like they are system variables? For example if I do a printenv from the 
pipeline "MyVar" shows up like its a system variable, I want it to show up like 
that from in my class too. Is there an elegant way of importing all the vars in 
"env" into my class and making them access like shell variables?


On Friday, December 1, 2017 at 9:08:12 AM UTC-5, Daniel Butler wrote:
If you’re writing a groovy class that’s run from a library in the pipeline 
script then you’re not going to be able to use System.getEnv().
 
There’s a few approaches you can take that do work:
• You can pass in the values you need as parameters to the methods/constructors 
you’re using.
• In the pipeline there’s the global variable `env` which is a map of all the 
currently declared environment variables (JOB_NAME etc) you could pass into 
your class.
• Pass in `this` from the pipeline script. You can then use this object to 
access anything in pipeline, (Let’s assume you called the field/parameter ctx) 
i.e. ctx.env.JOB_NAME or ctx.powershell(“write-host ‘spooky’”)
 
I noticed also you’ve got a direct execution of a process commented out, don’t 
do that either. The same way System.getEnv() doesn’t work, doing that will not 
behave as expected either (Assuming the sandbox will let you)
 
 
Regards,
Daniel.
 
From: red 888
Sent: 29 November 2017 20:28
To: Jenkins Users
Subject: Re: How can I inject environment variables into my groovy class?
 
So this is a problem for me because the APIs I'm using in the groovy class are 
looking for OS level environment variables.
 
Is there any way to set these variables with jenkins?

On Tuesday, November 28, 2017 at 5:54:37 PM UTC-5, mpapo - Michael Pailloncy 
wrote:
Pipeline environment variables are not stored at the OS level. That's why you 
are not able to get them using System.getenv() (which only list OS level 
environment variables).
But you should be able to retrieve them like any other classical environment 
variables : with the "${MyVar}" syntax inside your shared lib class.
 
Hopefully it helps.
 
Michaël
 
2017-11-28 22:30 GMT+01:00 red 888 :
My pipeline is using the environment directive to set an environment var and 
then calls a groovy class:
 
def call(int blah) {

    pipeline {
    agent any

    environment {
    MyVar = credentials('djsjflsjfljsf')
    }

    stages {
    stage('Stage ONE') {
    steps {
    echo test.methodA()
    
 
 
But from in my groovy class I don't see those environment variables:
 
// vars/test.groovy
 
class test implements Serializable {
    static methodA (){
    def env = System.getenv()
    return env.dump()
    //return ['powershell', 'ls env:'].execute().text
}

 
 
env.dump() and listing envs from the shell from inside the class doesn't show 
those variables I added in the environment directive. Can I change the scope of 
the class to give it access to these environment vars?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-- 
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/87b6e2b0-ed9a-4ede-b22c-3b06761345e1%40googlegroups.com.
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-use...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/6e7e1b97-7b9c-404f-9597-8577eb739b96%40googlegroups.com.
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 

Re: Build Docker Image from a Dockerized Jenkins

2017-12-03 Thread nicolas de loof
There's no "recommended" solution, each plugin comes with it's own vision,
benefits and drawbacks.

docker-plugin can be used to run dockerized agents, it can run from a
dockerized jenkins master with /var/run/docker.sock without docker CLI
installed, as it uses a java client library for docker API.
docker-slaves-plugin do rely on running docker CLI executed from master, I
planned to use a java API at some point but still need to work on this. In
the meantime I don't think there's a simple way to just install docker CLI.
Installing full docker will make your image a bit bigger with additional
files on filesystem but there won't be any extra process running, so not a
major issue (considering jenkins docker image is already a big one)

2017-12-03 18:42 GMT+01:00 Jeeva Chelladhurai :

> Hello All,
>
> I would like to build Docker images from a Dockerized Jenkins. There are
> multiple solution out there but what is the recommended solution...
>
> I have been using ssh node as a work around, but I was told to use
> https://wiki.jenkins.io/display/JENKINS/Docker+Slaves+Plugin . In order
> for this plugin to work, I have to install docker inside the Jenkins (my
> docker host is RHEL) and also mount the /var/run/docker.sock or enable
> TLS. Isn't installing docker blow up the size of the Jenkins image?
>
> Any way to install just the docker client in side the Jenkins image?
>
> Thanks,
> Jeeva
>
> --
> Jeeva K S Chelladhurai
>
> --
> 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/CAK5CbZV3Sc-fgYS_34PgEwRzsF20%
> 3Dp6mbaagbR2Ehtz01op2%3Dw%40mail.gmail.com
> 
> .
> 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/CANMVJzk7GJDmKUKQNvt4PzLpXHtTp%2B7BnikYfeysX7_kdpxcUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Build Docker Image from a Dockerized Jenkins

2017-12-03 Thread Jeeva Chelladhurai
Hello All,

I would like to build Docker images from a Dockerized Jenkins. There are
multiple solution out there but what is the recommended solution...

I have been using ssh node as a work around, but I was told to use
https://wiki.jenkins.io/display/JENKINS/Docker+Slaves+Plugin . In order for
this plugin to work, I have to install docker inside the Jenkins (my docker
host is RHEL) and also mount the /var/run/docker.sock or enable TLS. Isn't
installing docker blow up the size of the Jenkins image?

Any way to install just the docker client in side the Jenkins image?

Thanks,
Jeeva

-- 
Jeeva K S Chelladhurai

-- 
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/CAK5CbZV3Sc-fgYS_34PgEwRzsF20%3Dp6mbaagbR2Ehtz01op2%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.