CPdev
CPdev

Reputation: 495

Jenkins doesn't have label Linux

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

Upvotes: 17

Views: 57803

Answers (4)

Sandeep Pareek
Sandeep Pareek

Reputation: 1789

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

Upvotes: 0

Llorenç
Llorenç

Reputation: 1

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

Upvotes: -3

Michael Käfer
Michael Käfer

Reputation: 1796

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'
    }
    ...
}

Upvotes: 22

Mikki
Mikki

Reputation: 180

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.

Upvotes: 5

Related Questions