Jenkins doesn't have label Linux
Asked Answered
O

4

17

I am trying to run a Jenkins pipeline and I just keep getting the error:

Jenkins doesn't have label 'linux'

Any idea why this is happening? Is it a plugin I am missing?

pipeline {
    agent{
        label 'linux'
    }
    stages {
        stage('Checkout Code') {
            steps {
                checkout scm
            }
        }
        stage('Build Docker Container') {
            steps {
                script {
                    sh "ls -ltr"
                    env.HARBORHOST ="harbour.com"
                    env.REGISTRY = "securewbs"
                    env.IMAGE = "${env.HARBORHOST}/${env.REGISTRY}/securewbs:${env.BUILD_NUMBER}"
                    wbs = docker.build("${env.IMAGE}")
                }
            }
        }
Opinionative answered 4/10, 2018 at 10:27 Comment(0)
G
22

Go to Manage Jenkins->Manage Nodes. You can chose one of these nodes as your agent. Take the string from the column "name". If the name of one of your nodes is for example "master" you can write:

pipeline {
    agent {
        label 'master'
    }
    ...
}
Geometrize answered 18/4, 2019 at 16:9 Comment(2)
The accepted answer did not work for me so I posted a new one.Montes
On newer versions of jenkins it can be done by: Manage Jenkins >> Manage Nodes and Cloud >> Click Node (on which you want to add a label) >> Configure >> Add label. Labels are space separated if you want to add more than 1.Perri
A
5

Look at the configuration section of your Jenkins instance (https://your-jenkins/configure). There is a section called Lockable Resources Manager, and your 'linux' label should be listed here.
The label is a selection field.

Acne answered 4/10, 2018 at 10:56 Comment(4)
Solved thanks - needed to add a 'linux' label to the nodeOpinionative
How does one add this label? @calumpriceMoncada
@GeorgeUdosen There should be a field called "Label" in your-jenkins/configure Make sure that the label field of node block in your pipeline definition has the same value.Ammonal
>needed to add a 'linux' label to the node @CalumPrice // then the one from Michael Kafer should be the accepted answer. It also helped me to add a label to the node.Danit
T
0

you need to add new variable or name or like a constant (i don't no exact name)

step 1. click on this link: http://localhost:8080/manage/configureTools/
step 2. add tool whatever you want like: node, maven, jdk , etc.
step 3. if it's not visible then first you need to install plugin according to your requirement.
step 4. try again step 2 and use you created "Name" in jenkins file.

enter image description here

Tallula answered 16/6, 2023 at 13:13 Comment(0)
A
-3

if you can, avoid naming the agent, use pipeline { agent any ...

Acidulate answered 8/12, 2021 at 9:38 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewParing

© 2022 - 2024 — McMap. All rights reserved.