Image name and version of containerTemplate by variable created during execution of pipeline?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Image name and version of containerTemplate by variable created during execution of pipeline?

WANG, YAN-HONG
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

Carlos Sanchez

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <[hidden email]> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6P8rJ2kLDRQMaqugKeuPJSkeFR6Uyrpac%3Diz7h3bS6%3DPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

WANG, YAN-HONG
Hello Carlos,

I tried it already with all plain hard code. And insert in the execution of pipeline.

Something like this below:

podTemplate(

  label: "pod",

  containers: [
    containerTemplate(
      name: "worker",
      image: "myregistry:5000/jenkins-worker:latest",
      envVars:[
        containerEnvVar( key: "PGUSER", value: "pguser" ),
        containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
      ],
      alwaysPullImage: true,
      ttyEnabled: true,
      command: "cat"
    )
  ]
)
{
node( "pod" ) {

  container( "worker" ) {

    stage( "DB Tests" ) {

      containers: [
        containerTemplate(
          name: "db",
          image: "myregistry:5000/postgresql-server:1.0",
          alwaysPullImage: true,
          ttyEnabled: true
        )
      ]


      container( "db" ) {
        sh "psql --host=127.0.0.1 --dbname=$project --echo-all --command='SELECT timestamp FROM info'"
      }
    }
  }
}
}

And I got the error message result below:

Waiting for container container [db] of pod [slave-87s57-3zc4x] to become ready.

Do I make something wrong in script?
Or that need to be implemented by other form or syntax?

Thanks very much.

BR
Hong

Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="t3WCPPFGCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">allway...@...> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
<a href="https://github.com/jenkinsci/kubernetes-plugin" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELoZSzHJHwtveGXdhrPILETqOiYA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELoZSzHJHwtveGXdhrPILETqOiYA&#39;;return true;">https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="t3WCPPFGCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

Carlos Sanchez
you can't define containers outside podTemplate

On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

I tried it already with all plain hard code. And insert in the execution of pipeline.

Something like this below:

podTemplate(

  label: "pod",

  containers: [
    containerTemplate(
      name: "worker",
      image: "myregistry:5000/jenkins-worker:latest",
      envVars:[
        containerEnvVar( key: "PGUSER", value: "pguser" ),
        containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
      ],
      alwaysPullImage: true,
      ttyEnabled: true,
      command: "cat"
    )
  ]
)
{
node( "pod" ) {

  container( "worker" ) {

    stage( "DB Tests" ) {

      containers: [
        containerTemplate(
          name: "db",
          image: "myregistry:5000/postgresql-server:1.0",
          alwaysPullImage: true,
          ttyEnabled: true
        )
      ]


      container( "db" ) {
        sh "psql --host=127.0.0.1 --dbname=$project --echo-all --command='SELECT timestamp FROM info'"
      }
    }
  }
}
}

And I got the error message result below:

Waiting for container container [db] of pod [slave-87s57-3zc4x] to become ready.

Do I make something wrong in script?
Or that need to be implemented by other form or syntax?

Thanks very much.

BR
Hong

Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <[hidden email]> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6Mohh7jSYwQ6_ke7DrZomJ9hpxrtSqfuLoKTh5tNG0Whw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

WANG, YAN-HONG
Hello Carlos,

Thanks for correction.
But, if containerTemplate can't be defined outside of podTemplate.

How could I create a container in the execution of pipeline?
And that container can also stay in the same pod.
Is there some other syntax or some container creation function could be applied in node area?

Thanks very much again.

Best regards,
Hong

Am Montag, 14. August 2017 09:42:11 UTC+2 schrieb Carlos Sanchez:
you can't define containers outside podTemplate

On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RlmI7rFiCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">allway...@...> wrote:
Hello Carlos,

I tried it already with all plain hard code. And insert in the execution of pipeline.

Something like this below:

podTemplate(

  label: "pod",

  containers: [
    containerTemplate(
      name: "worker",
      image: "myregistry:5000/jenkins-worker:latest",
      envVars:[
        containerEnvVar( key: "PGUSER", value: "pguser" ),
        containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
      ],
      alwaysPullImage: true,
      ttyEnabled: true,
      command: "cat"
    )
  ]
)
{
node( "pod" ) {

  container( "worker" ) {

    stage( "DB Tests" ) {

      containers: [
        containerTemplate(
          name: "db",
          image: "myregistry:5000/postgresql-server:1.0",
          alwaysPullImage: true,
          ttyEnabled: true
        )
      ]


      container( "db" ) {
        sh "psql --host=127.0.0.1 --dbname=$project --echo-all --command='SELECT timestamp FROM info'"
      }
    }
  }
}
}

And I got the error message result below:

Waiting for container container [db] of pod [slave-87s57-3zc4x] to become ready.

Do I make something wrong in script?
Or that need to be implemented by other form or syntax?

Thanks very much.

BR
Hong

Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <[hidden email]> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
<a href="https://github.com/jenkinsci/kubernetes-plugin" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELoZSzHJHwtveGXdhrPILETqOiYA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELoZSzHJHwtveGXdhrPILETqOiYA&#39;;return true;">https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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 <a href="https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="RlmI7rFiCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com.

For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/801babe3-3e2d-47bf-abc5-9b2b5dfb3a8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

WANG, YAN-HONG
Hello Carlos,

If I use the container created function like below:

def dbImage = docker.image( "myregistry:5000/imagename:1.0.0.1" )
def c = dbImage.run("--network jenkins-network --name mycontainer")

But, this container seems will be created in host side, not in Kubernetes side, right?

So this container even was created ... but it could not communicate with other container ...

Best regards,
Hong

Am Montag, 14. August 2017 20:32:19 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for correction.
But, if containerTemplate can't be defined outside of podTemplate.

How could I create a container in the execution of pipeline?
And that container can also stay in the same pod.
Is there some other syntax or some container creation function could be applied in node area?

Thanks very much again.

Best regards,
Hong

Am Montag, 14. August 2017 09:42:11 UTC+2 schrieb Carlos Sanchez:
you can't define containers outside podTemplate

On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

I tried it already with all plain hard code. And insert in the execution of pipeline.

Something like this below:

podTemplate(

  label: "pod",

  containers: [
    containerTemplate(
      name: "worker",
      image: "myregistry:5000/jenkins-worker:latest",
      envVars:[
        containerEnvVar( key: "PGUSER", value: "pguser" ),
        containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
      ],
      alwaysPullImage: true,
      ttyEnabled: true,
      command: "cat"
    )
  ]
)
{
node( "pod" ) {

  container( "worker" ) {

    stage( "DB Tests" ) {

      containers: [
        containerTemplate(
          name: "db",
          image: "myregistry:5000/postgresql-server:1.0",
          alwaysPullImage: true,
          ttyEnabled: true
        )
      ]


      container( "db" ) {
        sh "psql --host=127.0.0.1 --dbname=$project --echo-all --command='SELECT timestamp FROM info'"
      }
    }
  }
}
}

And I got the error message result below:

Waiting for container container [db] of pod [slave-87s57-3zc4x] to become ready.

Do I make something wrong in script?
Or that need to be implemented by other form or syntax?

Thanks very much.

BR
Hong

Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <[hidden email]> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
<a href="https://github.com/jenkinsci/kubernetes-plugin" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELoZSzHJHwtveGXdhrPILETqOiYA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELoZSzHJHwtveGXdhrPILETqOiYA&#39;;return true;">https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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 <a href="https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 <a href="https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com.

For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/800b3663-ec78-4223-8718-2ed7ba781256%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

Carlos Sanchez
You can not add containers to a pod after the pod is created, that doesn't work in kubernetes nor docker swarm

On Mon, Aug 14, 2017 at 8:44 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

If I use the container created function like below:

def dbImage = docker.image( "myregistry:5000/imagename:1.0.0.1" )
def c = dbImage.run("--network jenkins-network --name mycontainer")

But, this container seems will be created in host side, not in Kubernetes side, right?

So this container even was created ... but it could not communicate with other container ...

Best regards,
Hong


Am Montag, 14. August 2017 20:32:19 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for correction.
But, if containerTemplate can't be defined outside of podTemplate.

How could I create a container in the execution of pipeline?
And that container can also stay in the same pod.
Is there some other syntax or some container creation function could be applied in node area?

Thanks very much again.

Best regards,
Hong

Am Montag, 14. August 2017 09:42:11 UTC+2 schrieb Carlos Sanchez:
you can't define containers outside podTemplate

On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

I tried it already with all plain hard code. And insert in the execution of pipeline.

Something like this below:

podTemplate(

  label: "pod",

  containers: [
    containerTemplate(
      name: "worker",
      image: "myregistry:5000/jenkins-worker:latest",
      envVars:[
        containerEnvVar( key: "PGUSER", value: "pguser" ),
        containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
      ],
      alwaysPullImage: true,
      ttyEnabled: true,
      command: "cat"
    )
  ]
)
{
node( "pod" ) {

  container( "worker" ) {

    stage( "DB Tests" ) {

      containers: [
        containerTemplate(
          name: "db",
          image: "myregistry:5000/postgresql-server:1.0",
          alwaysPullImage: true,
          ttyEnabled: true
        )
      ]


      container( "db" ) {
        sh "psql --host=127.0.0.1 --dbname=$project --echo-all --command='SELECT timestamp FROM info'"
      }
    }
  }
}
}

And I got the error message result below:

Waiting for container container [db] of pod [slave-87s57-3zc4x] to become ready.

Do I make something wrong in script?
Or that need to be implemented by other form or syntax?

Thanks very much.

BR
Hong

Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <[hidden email]> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/800b3663-ec78-4223-8718-2ed7ba781256%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6PZLE2Q0TCcd5626q%3Da3zKD77y3R9_8HvpnG4Foi5EJPA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

WANG, YAN-HONG
Hello Carlos,

Thanks for your hint.
I will try to create new container in other new pod.

Hong

Am Montag, 14. August 2017 21:20:03 UTC+2 schrieb Carlos Sanchez:
You can not add containers to a pod after the pod is created, that doesn't work in kubernetes nor docker swarm

On Mon, Aug 14, 2017 at 8:44 PM, YAN-HONG WANG <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="JnAc9saICQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">allway...@...> wrote:
Hello Carlos,

If I use the container created function like below:

def dbImage = docker.image( "myregistry:5000/imagename:1.0.0.1" )
def c = dbImage.run("--network jenkins-network --name mycontainer")

But, this container seems will be created in host side, not in Kubernetes side, right?

So this container even was created ... but it could not communicate with other container ...

Best regards,
Hong


Am Montag, 14. August 2017 20:32:19 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for correction.
But, if containerTemplate can't be defined outside of podTemplate.

How could I create a container in the execution of pipeline?
And that container can also stay in the same pod.
Is there some other syntax or some container creation function could be applied in node area?

Thanks very much again.

Best regards,
Hong

Am Montag, 14. August 2017 09:42:11 UTC+2 schrieb Carlos Sanchez:
you can't define containers outside podTemplate

On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

I tried it already with all plain hard code. And insert in the execution of pipeline.

Something like this below:

podTemplate(

  label: "pod",

  containers: [
    containerTemplate(
      name: "worker",
      image: "myregistry:5000/jenkins-worker:latest",
      envVars:[
        containerEnvVar( key: "PGUSER", value: "pguser" ),
        containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
      ],
      alwaysPullImage: true,
      ttyEnabled: true,
      command: "cat"
    )
  ]
)
{
node( "pod" ) {

  container( "worker" ) {

    stage( "DB Tests" ) {

      containers: [
        containerTemplate(
          name: "db",
          image: "myregistry:5000/postgresql-server:1.0",
          alwaysPullImage: true,
          ttyEnabled: true
        )
      ]


      container( "db" ) {
        sh "psql --host=127.0.0.1 --dbname=$project --echo-all --command='SELECT timestamp FROM info'"
      }
    }
  }
}
}

And I got the error message result below:

Waiting for container container [db] of pod [slave-87s57-3zc4x] to become ready.

Do I make something wrong in script?
Or that need to be implemented by other form or syntax?

Thanks very much.

BR
Hong

Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <[hidden email]> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
<a href="https://github.com/jenkinsci/kubernetes-plugin" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELoZSzHJHwtveGXdhrPILETqOiYA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELoZSzHJHwtveGXdhrPILETqOiYA&#39;;return true;">https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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 <a href="https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 <a href="https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com.

For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="JnAc9saICQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/800b3663-ec78-4223-8718-2ed7ba781256%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/800b3663-ec78-4223-8718-2ed7ba781256%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/800b3663-ec78-4223-8718-2ed7ba781256%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/800b3663-ec78-4223-8718-2ed7ba781256%40googlegroups.com.

For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/511c7963-8af0-4d55-8bfa-a55c0e6ca205%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

WANG, YAN-HONG
Hello Carlos,

Now in my Jenkinsfile.groovy I create a slave container in other pod.
I use "load" this function to implement.

But, I found out that pod will be destroyed automatically when that slave container was executed.
That slave container is a PostgreSQL daemon. That needs to be held for waiting other container binding.
And then unfortunately that slave container was destroyed by destroyed pod.

Is there any syntax or podTemplate argument can avoid pod destroyed automatically?

Thanks very much.

Best regards,
Hong

Am Montag, 14. August 2017 21:58:46 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for your hint.
I will try to create new container in other new pod.

Hong

Am Montag, 14. August 2017 21:20:03 UTC+2 schrieb Carlos Sanchez:
You can not add containers to a pod after the pod is created, that doesn't work in kubernetes nor docker swarm

On Mon, Aug 14, 2017 at 8:44 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

If I use the container created function like below:

def dbImage = docker.image( "myregistry:5000/imagename:1.0.0.1" )
def c = dbImage.run("--network jenkins-network --name mycontainer")

But, this container seems will be created in host side, not in Kubernetes side, right?

So this container even was created ... but it could not communicate with other container ...

Best regards,
Hong


Am Montag, 14. August 2017 20:32:19 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for correction.
But, if containerTemplate can't be defined outside of podTemplate.

How could I create a container in the execution of pipeline?
And that container can also stay in the same pod.
Is there some other syntax or some container creation function could be applied in node area?

Thanks very much again.

Best regards,
Hong

Am Montag, 14. August 2017 09:42:11 UTC+2 schrieb Carlos Sanchez:
you can't define containers outside podTemplate

On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

I tried it already with all plain hard code. And insert in the execution of pipeline.

Something like this below:

podTemplate(

  label: "pod",

  containers: [
    containerTemplate(
      name: "worker",
      image: "myregistry:5000/jenkins-worker:latest",
      envVars:[
        containerEnvVar( key: "PGUSER", value: "pguser" ),
        containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
      ],
      alwaysPullImage: true,
      ttyEnabled: true,
      command: "cat"
    )
  ]
)
{
node( "pod" ) {

  container( "worker" ) {

    stage( "DB Tests" ) {

      containers: [
        containerTemplate(
          name: "db",
          image: "myregistry:5000/postgresql-server:1.0",
          alwaysPullImage: true,
          ttyEnabled: true
        )
      ]


      container( "db" ) {
        sh "psql --host=127.0.0.1 --dbname=$project --echo-all --command='SELECT timestamp FROM info'"
      }
    }
  }
}
}

And I got the error message result below:

Waiting for container container [db] of pod [slave-87s57-3zc4x] to become ready.

Do I make something wrong in script?
Or that need to be implemented by other form or syntax?

Thanks very much.

BR
Hong

Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <[hidden email]> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
<a href="https://github.com/jenkinsci/kubernetes-plugin" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELoZSzHJHwtveGXdhrPILETqOiYA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNELoZSzHJHwtveGXdhrPILETqOiYA&#39;;return true;">https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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 <a href="https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%40mail.gmail.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 <a href="https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%40googlegroups.com.

For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 <a href="https://groups.google.com/d/msgid/jenkinsci-users/800b3663-ec78-4223-8718-2ed7ba781256%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/800b3663-ec78-4223-8718-2ed7ba781256%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/800b3663-ec78-4223-8718-2ed7ba781256%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/800b3663-ec78-4223-8718-2ed7ba781256%40googlegroups.com.

For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/afbe15cf-35c9-4b99-a795-a73961c0f910%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

Carlos Sanchez


On Wed, Aug 16, 2017 at 1:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

Now in my Jenkinsfile.groovy I create a slave container in other pod.
I use "load" this function to implement.

But, I found out that pod will be destroyed automatically when that slave container was executed.
That slave container is a PostgreSQL daemon. That needs to be held for waiting other container binding.
And then unfortunately that slave container was destroyed by destroyed pod.

Is there any syntax or podTemplate argument can avoid pod destroyed automatically?

You can create multiple containers as part of a pod, then can use them until podTemplate is closed, when the pod is destroyed
 

Thanks very much.

Best regards,
Hong


Am Montag, 14. August 2017 21:58:46 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for your hint.
I will try to create new container in other new pod.

Hong

Am Montag, 14. August 2017 21:20:03 UTC+2 schrieb Carlos Sanchez:
You can not add containers to a pod after the pod is created, that doesn't work in kubernetes nor docker swarm

On Mon, Aug 14, 2017 at 8:44 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

If I use the container created function like below:

def dbImage = docker.image( "myregistry:5000/imagename:1.0.0.1" )
def c = dbImage.run("--network jenkins-network --name mycontainer")

But, this container seems will be created in host side, not in Kubernetes side, right?

So this container even was created ... but it could not communicate with other container ...

Best regards,
Hong


Am Montag, 14. August 2017 20:32:19 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for correction.
But, if containerTemplate can't be defined outside of podTemplate.

How could I create a container in the execution of pipeline?
And that container can also stay in the same pod.
Is there some other syntax or some container creation function could be applied in node area?

Thanks very much again.

Best regards,
Hong

Am Montag, 14. August 2017 09:42:11 UTC+2 schrieb Carlos Sanchez:
you can't define containers outside podTemplate

On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

I tried it already with all plain hard code. And insert in the execution of pipeline.

Something like this below:

podTemplate(

  label: "pod",

  containers: [
    containerTemplate(
      name: "worker",
      image: "myregistry:5000/jenkins-worker:latest",
      envVars:[
        containerEnvVar( key: "PGUSER", value: "pguser" ),
        containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
      ],
      alwaysPullImage: true,
      ttyEnabled: true,
      command: "cat"
    )
  ]
)
{
node( "pod" ) {

  container( "worker" ) {

    stage( "DB Tests" ) {

      containers: [
        containerTemplate(
          name: "db",
          image: "myregistry:5000/postgresql-server:1.0",
          alwaysPullImage: true,
          ttyEnabled: true
        )
      ]


      container( "db" ) {
        sh "psql --host=127.0.0.1 --dbname=$project --echo-all --command='SELECT timestamp FROM info'"
      }
    }
  }
}
}

And I got the error message result below:

Waiting for container container [db] of pod [slave-87s57-3zc4x] to become ready.

Do I make something wrong in script?
Or that need to be implemented by other form or syntax?

Thanks very much.

BR
Hong

Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <[hidden email]> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%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/800b3663-ec78-4223-8718-2ed7ba781256%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/afbe15cf-35c9-4b99-a795-a73961c0f910%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6NsOu2iE2UBNdhDFg90A4q5dszG_ZJzfaMD-nT0-Yr%3DQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

WANG, YAN-HONG
Hello Carlos,

Thanks for your reply and explanation.

My situation is that one of container images doesn't exist in the beginning of pod creation.
And then that container image will be established in the "build stage" of pipeline execution.

So that is why I cannot let this containerTemplate claimed in the beginning of Pod Definition.

Best regards,
Hong

2017-08-16 17:01 GMT+02:00 Carlos Sanchez <[hidden email]>:


On Wed, Aug 16, 2017 at 1:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

Now in my Jenkinsfile.groovy I create a slave container in other pod.
I use "load" this function to implement.

But, I found out that pod will be destroyed automatically when that slave container was executed.
That slave container is a PostgreSQL daemon. That needs to be held for waiting other container binding.
And then unfortunately that slave container was destroyed by destroyed pod.

Is there any syntax or podTemplate argument can avoid pod destroyed automatically?

You can create multiple containers as part of a pod, then can use them until podTemplate is closed, when the pod is destroyed
 

Thanks very much.

Best regards,
Hong


Am Montag, 14. August 2017 21:58:46 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for your hint.
I will try to create new container in other new pod.

Hong

Am Montag, 14. August 2017 21:20:03 UTC+2 schrieb Carlos Sanchez:
You can not add containers to a pod after the pod is created, that doesn't work in kubernetes nor docker swarm

On Mon, Aug 14, 2017 at 8:44 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

If I use the container created function like below:

def dbImage = docker.image( "myregistry:5000/imagename:1.0.0.1" )
def c = dbImage.run("--network jenkins-network --name mycontainer")

But, this container seems will be created in host side, not in Kubernetes side, right?

So this container even was created ... but it could not communicate with other container ...

Best regards,
Hong


Am Montag, 14. August 2017 20:32:19 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for correction.
But, if containerTemplate can't be defined outside of podTemplate.

How could I create a container in the execution of pipeline?
And that container can also stay in the same pod.
Is there some other syntax or some container creation function could be applied in node area?

Thanks very much again.

Best regards,
Hong

Am Montag, 14. August 2017 09:42:11 UTC+2 schrieb Carlos Sanchez:
you can't define containers outside podTemplate

On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

I tried it already with all plain hard code. And insert in the execution of pipeline.

Something like this below:

podTemplate(

  label: "pod",

  containers: [
    containerTemplate(
      name: "worker",
      image: "myregistry:5000/jenkins-worker:latest",
      envVars:[
        containerEnvVar( key: "PGUSER", value: "pguser" ),
        containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
      ],
      alwaysPullImage: true,
      ttyEnabled: true,
      command: "cat"
    )
  ]
)
{
node( "pod" ) {

  container( "worker" ) {

    stage( "DB Tests" ) {

      containers: [
        containerTemplate(
          name: "db",
          image: "myregistry:5000/postgresql-server:1.0",
          alwaysPullImage: true,
          ttyEnabled: true
        )
      ]


      container( "db" ) {
        sh "psql --host=127.0.0.1 --dbname=$project --echo-all --command='SELECT timestamp FROM info'"
      }
    }
  }
}
}

And I got the error message result below:

Waiting for container container [db] of pod [slave-87s57-3zc4x] to become ready.

Do I make something wrong in script?
Or that need to be implemented by other form or syntax?

Thanks very much.

BR
Hong

Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <[hidden email]> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%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/800b3663-ec78-4223-8718-2ed7ba781256%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/afbe15cf-35c9-4b99-a795-a73961c0f910%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/m5ZXydq8gtc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6NsOu2iE2UBNdhDFg90A4q5dszG_ZJzfaMD-nT0-Yr%3DQw%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO2R48h977p%2BD94-WTQgz8o0Zz9Q%3D1R5CWeG4ocYKg%3DPmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

Carlos Sanchez
The you would need 2 podTemplate entries, one after another

On Thu, Aug 17, 2017 at 10:59 PM, WANG, YAN-HONG <[hidden email]> wrote:
Hello Carlos,

Thanks for your reply and explanation.

My situation is that one of container images doesn't exist in the beginning of pod creation.
And then that container image will be established in the "build stage" of pipeline execution.

So that is why I cannot let this containerTemplate claimed in the beginning of Pod Definition.

Best regards,
Hong

2017-08-16 17:01 GMT+02:00 Carlos Sanchez <[hidden email]>:


On Wed, Aug 16, 2017 at 1:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

Now in my Jenkinsfile.groovy I create a slave container in other pod.
I use "load" this function to implement.

But, I found out that pod will be destroyed automatically when that slave container was executed.
That slave container is a PostgreSQL daemon. That needs to be held for waiting other container binding.
And then unfortunately that slave container was destroyed by destroyed pod.

Is there any syntax or podTemplate argument can avoid pod destroyed automatically?

You can create multiple containers as part of a pod, then can use them until podTemplate is closed, when the pod is destroyed
 

Thanks very much.

Best regards,
Hong


Am Montag, 14. August 2017 21:58:46 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for your hint.
I will try to create new container in other new pod.

Hong

Am Montag, 14. August 2017 21:20:03 UTC+2 schrieb Carlos Sanchez:
You can not add containers to a pod after the pod is created, that doesn't work in kubernetes nor docker swarm

On Mon, Aug 14, 2017 at 8:44 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

If I use the container created function like below:

def dbImage = docker.image( "myregistry:5000/imagename:1.0.0.1" )
def c = dbImage.run("--network jenkins-network --name mycontainer")

But, this container seems will be created in host side, not in Kubernetes side, right?

So this container even was created ... but it could not communicate with other container ...

Best regards,
Hong


Am Montag, 14. August 2017 20:32:19 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for correction.
But, if containerTemplate can't be defined outside of podTemplate.

How could I create a container in the execution of pipeline?
And that container can also stay in the same pod.
Is there some other syntax or some container creation function could be applied in node area?

Thanks very much again.

Best regards,
Hong

Am Montag, 14. August 2017 09:42:11 UTC+2 schrieb Carlos Sanchez:
you can't define containers outside podTemplate

On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

I tried it already with all plain hard code. And insert in the execution of pipeline.

Something like this below:

podTemplate(

  label: "pod",

  containers: [
    containerTemplate(
      name: "worker",
      image: "myregistry:5000/jenkins-worker:latest",
      envVars:[
        containerEnvVar( key: "PGUSER", value: "pguser" ),
        containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
      ],
      alwaysPullImage: true,
      ttyEnabled: true,
      command: "cat"
    )
  ]
)
{
node( "pod" ) {

  container( "worker" ) {

    stage( "DB Tests" ) {

      containers: [
        containerTemplate(
          name: "db",
          image: "myregistry:5000/postgresql-server:1.0",
          alwaysPullImage: true,
          ttyEnabled: true
        )
      ]


      container( "db" ) {
        sh "psql --host=127.0.0.1 --dbname=$project --echo-all --command='SELECT timestamp FROM info'"
      }
    }
  }
}
}

And I got the error message result below:

Waiting for container container [db] of pod [slave-87s57-3zc4x] to become ready.

Do I make something wrong in script?
Or that need to be implemented by other form or syntax?

Thanks very much.

BR
Hong

Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <[hidden email]> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%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/800b3663-ec78-4223-8718-2ed7ba781256%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/afbe15cf-35c9-4b99-a795-a73961c0f910%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/m5ZXydq8gtc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6NsOu2iE2UBNdhDFg90A4q5dszG_ZJzfaMD-nT0-Yr%3DQw%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO2R48h977p%2BD94-WTQgz8o0Zz9Q%3D1R5CWeG4ocYKg%3DPmQ%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6Nc3xJ%2B6xqePrdqpOz3nDzdacG%3DEae_Rbjer9Dz-gw3bA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Image name and version of containerTemplate by variable created during execution of pipeline?

WANG, YAN-HONG
Hello Carlos,

Thanks for your hint. I will try it.

Hong

2017-08-18 9:42 GMT+02:00 Carlos Sanchez <[hidden email]>:
The you would need 2 podTemplate entries, one after another

On Thu, Aug 17, 2017 at 10:59 PM, WANG, YAN-HONG <[hidden email]> wrote:
Hello Carlos,

Thanks for your reply and explanation.

My situation is that one of container images doesn't exist in the beginning of pod creation.
And then that container image will be established in the "build stage" of pipeline execution.

So that is why I cannot let this containerTemplate claimed in the beginning of Pod Definition.

Best regards,
Hong

2017-08-16 17:01 GMT+02:00 Carlos Sanchez <[hidden email]>:


On Wed, Aug 16, 2017 at 1:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

Now in my Jenkinsfile.groovy I create a slave container in other pod.
I use "load" this function to implement.

But, I found out that pod will be destroyed automatically when that slave container was executed.
That slave container is a PostgreSQL daemon. That needs to be held for waiting other container binding.
And then unfortunately that slave container was destroyed by destroyed pod.

Is there any syntax or podTemplate argument can avoid pod destroyed automatically?

You can create multiple containers as part of a pod, then can use them until podTemplate is closed, when the pod is destroyed
 

Thanks very much.

Best regards,
Hong


Am Montag, 14. August 2017 21:58:46 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for your hint.
I will try to create new container in other new pod.

Hong

Am Montag, 14. August 2017 21:20:03 UTC+2 schrieb Carlos Sanchez:
You can not add containers to a pod after the pod is created, that doesn't work in kubernetes nor docker swarm

On Mon, Aug 14, 2017 at 8:44 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

If I use the container created function like below:

def dbImage = docker.image( "myregistry:5000/imagename:1.0.0.1" )
def c = dbImage.run("--network jenkins-network --name mycontainer")

But, this container seems will be created in host side, not in Kubernetes side, right?

So this container even was created ... but it could not communicate with other container ...

Best regards,
Hong


Am Montag, 14. August 2017 20:32:19 UTC+2 schrieb YAN-HONG WANG:
Hello Carlos,

Thanks for correction.
But, if containerTemplate can't be defined outside of podTemplate.

How could I create a container in the execution of pipeline?
And that container can also stay in the same pod.
Is there some other syntax or some container creation function could be applied in node area?

Thanks very much again.

Best regards,
Hong

Am Montag, 14. August 2017 09:42:11 UTC+2 schrieb Carlos Sanchez:
you can't define containers outside podTemplate

On Fri, Aug 11, 2017 at 11:55 PM, YAN-HONG WANG <[hidden email]> wrote:
Hello Carlos,

I tried it already with all plain hard code. And insert in the execution of pipeline.

Something like this below:

podTemplate(

  label: "pod",

  containers: [
    containerTemplate(
      name: "worker",
      image: "myregistry:5000/jenkins-worker:latest",
      envVars:[
        containerEnvVar( key: "PGUSER", value: "pguser" ),
        containerEnvVar( key: "PGPASSWORD", value: "pgpassword" )
      ],
      alwaysPullImage: true,
      ttyEnabled: true,
      command: "cat"
    )
  ]
)
{
node( "pod" ) {

  container( "worker" ) {

    stage( "DB Tests" ) {

      containers: [
        containerTemplate(
          name: "db",
          image: "myregistry:5000/postgresql-server:1.0",
          alwaysPullImage: true,
          ttyEnabled: true
        )
      ]


      container( "db" ) {
        sh "psql --host=127.0.0.1 --dbname=$project --echo-all --command='SELECT timestamp FROM info'"
      }
    }
  }
}
}

And I got the error message result below:

Waiting for container container [db] of pod [slave-87s57-3zc4x] to become ready.

Do I make something wrong in script?
Or that need to be implemented by other form or syntax?

Thanks very much.

BR
Hong

Am Freitag, 11. August 2017 14:57:50 UTC+2 schrieb Carlos Sanchez:

Have you tried?


On Fri, Aug 11, 2017, 12:14 WANG, YAN-HONG <[hidden email]> wrote:
Hello all,

I saw the tutorial with jenkins-kubernetes-plugin.
https://github.com/jenkinsci/kubernetes-plugin

The examples of containerTemplate are all created in the beginning of groovy file.
And the image name with version number are fixed, too.
Example like this below.

containerTemplate(
    name
: 'maven',
    image: 'maven:3.3.9-jdk-8-alpine',
    ttyEnabled: true,
    command: 'cat'
)

Is that possible or some syntax can implement container created during execution of pipeline?
So this container could also run in the same Pod.
Maybe the syntax looks like below.

//////////////////////////////////////////////////////////////////////

......
......

containerTemplate(
    name
: 'maven',
    image: 'myregistry:5000/$ImageName:$VersionNumber',
    ttyEnabled: true,
    command: 'cat'
)

......
......

//////////////////////////////////////////////////////////////////////

Thanks very much.

BR
Hong

--
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/CADLWyO3katWvkMezE80XJ8u%3DFna_QW5%2BjWT12PYa%3Dar_BUgAxQ%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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6d679b02-1099-45a8-a35b-c89e25fae0a5%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/800b3663-ec78-4223-8718-2ed7ba781256%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/afbe15cf-35c9-4b99-a795-a73961c0f910%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/m5ZXydq8gtc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6NsOu2iE2UBNdhDFg90A4q5dszG_ZJzfaMD-nT0-Yr%3DQw%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO2R48h977p%2BD94-WTQgz8o0Zz9Q%3D1R5CWeG4ocYKg%3DPmQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/m5ZXydq8gtc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6Nc3xJ%2B6xqePrdqpOz3nDzdacG%3DEae_Rbjer9Dz-gw3bA%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CADLWyO2pHLhKP5GQaNy-TypGe-LAmVM1jHtYp0W3MChWBN3p-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...