OK, so this is what I have as a POC. I don't see why the pods i'm creating
are called 'jenkins-slave' when the pod template i'm inheriting has the
pods named 'jenkins-builder'
def label = "jenkins-builder-${UUID.randomUUID().toString()}"
podTemplate(label: label, inheritFrom: 'jenkins-builder', containers: [
containerTemplate(name: 'kubectl', image: '<redact>', command:
'cat', ttyEnabled: true),
containerTemplate(name: 'helm', image: '<redact>', command: 'cat',
ttyEnabled: true),
containerTemplate(name: 'jenkins-agent', image: '<redact>', command:
'cat', ttyEnabled: true)
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath:
'/var/run/docker.sock')
]) {
node(label) {
def myRepo = checkout scm
def gitCommit = myRepo.GIT_COMMIT
def gitBranch = myRepo.GIT_BRANCH
def shortGitCommit = "${gitCommit[0..10]}"
def previousGitCommit = sh(script: "git rev-parse ${gitCommit}~",
returnStdout: true)
stage('Create Docker images') {
container('jenkins-agent') {
sh """
\$(aws ecr get-login --no-include-email --region=us-west-2 |
sed 's/-e none//')
docker build -t <redact>:${gitCommit} . -f base.Dockerfile
docker push <redact>:${gitCommit}
"""
}
}
stage('Run kubectl') {
container('kubectl') {
sh "kubectl get pods"
}
}
stage('Run helm') {
container('helm') {
sh "helm list"
}
}
}
}
On Tue, Aug 28, 2018 at 1:10 PM, Carlos Sanchez <[email protected]> wrote:
> It depends on what are you trying to do which is not clear. If you are
> building a pipeline job you need to use
>
> node(label) {}
> or in declarative
> agent { label 'my-defined-label' }
>
> or use the k8s plugin pipeline capabilities
>
> see
> https://wiki.jenkins.io/display/JENKINS/Distributed+
> builds#Distributedbuilds-Usinglabels
> https://jenkins.io/doc/book/pipeline/syntax/#agent
> https://github.com/jenkinsci/kubernetes-plugin/
>
>
> On Tue, Aug 28, 2018 at 10:02 PM Gabe Nydick <[email protected]> wrote:
>
>> Oh, and which plugin, is this a kubernetes plugin issue or multi-branch?
>>
>> On Tue, Aug 28, 2018 at 1:01 PM, Gabe Nydick <[email protected]> wrote:
>>
>>> I don't see where I can add labels to my job.
>>>
>>> On Tue, Aug 28, 2018 at 1:00 PM, Gabe Nydick <[email protected]> wrote:
>>>
>>>> Exactly that section. So I have to add labels to my multi-branch job to
>>>> match the labels in the template?
>>>>
>>>> On Tue, Aug 28, 2018 at 12:53 PM, Carlos Sanchez <[email protected]>
>>>> wrote:
>>>>
>>>>> > When I configure a multi-branch pipeline, the Kubernetes cluster
>>>>> section
>>>>>
>>>>> are you talking about the section that says "Allow pipeline support
>>>>> for the following restricted Kubernetes Clouds"
>>>>> that's only for security restrictions
>>>>>
>>>>> You have to check what labels do you have defined in your pod template
>>>>> config and what labels your job uses. Check the logs for more detailed
>>>>> info, see debugging section in the plugin readme
>>>>>
>>>>>
>>>>> On Tue, Aug 28, 2018 at 8:54 PM Gabe Nydick <[email protected]> wrote:
>>>>>
>>>>>> I have a successfully configured kubernetes cluster that runs my
>>>>>> build jobs. When I configure a multi-branch pipeline, the Kubernetes
>>>>>> cluster section just has ' -- none -- '. The multi-branch pipeline still
>>>>>> runs, but it has errors that are in a different topic email, so I'll keep
>>>>>> that there, but instead of using the pod template that runs all of the
>>>>>> freestyle jobs, this one uses some other template that I can't find,
>>>>>> maybe
>>>>>> it's a default in the plugin code.
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Jenkins Users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>>> msgid/jenkinsci-users/CACTWNKCvtmNXpbG-8uA3A4HPSq%
>>>>>> 3DuXCztpiXFpoS3XRUy1pt2FQ%40mail.gmail.com
>>>>>> <https://groups.google.com/d/msgid/jenkinsci-users/CACTWNKCvtmNXpbG-8uA3A4HPSq%3DuXCztpiXFpoS3XRUy1pt2FQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Jenkins Users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>> msgid/jenkinsci-users/CALHFn6OTvFjB7KT_ZjKkUmHgzGkAHbw1cVp5fKBfB5EYTp
>>>>> _egw%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6OTvFjB7KT_ZjKkUmHgzGkAHbw1cVp5fKBfB5EYTp_egw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/jenkinsci-users/CACTWNKBZ%2BaEVZL_JdpY8a%
>> 2B59m8MTBgWtMtVvQCsmFpT0r8y7Tg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/jenkinsci-users/CACTWNKBZ%2BaEVZL_JdpY8a%2B59m8MTBgWtMtVvQCsmFpT0r8y7Tg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jenkinsci-users/CALHFn6PwNu7z523OTQCavSBne%
> 2Bcpq1WQHwxRus-w-5J%3DKnCBpQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6PwNu7z523OTQCavSBne%2Bcpq1WQHwxRus-w-5J%3DKnCBpQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/CACTWNKBNW1TMZy%3DTxj64K74dze0fZ__-mxYKA1fX_-ATi0HpFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.