Jenkins doesn't have label Linux

53.3k Views Asked by At

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}")
                }
            }
        }
4

There are 4 best solutions below

2
Michael Käfer On BEST ANSWER

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'
    }
    ...
}
4
Mikki On

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.

1
Llorenç On

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

0
Sandeep Pareek On

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