Operations 6 min read

Why Jenkins Can’t Find Your ‘linux’ Label and How to Fix It on AWS EC2

This guide walks through two common issues when using the Jenkins AWS EC2 plugin—missing node labels and a cluttered console full of terminated instances—explaining why they occur, how to adjust remote user settings and init scripts, and practical steps to clean up and optimize the plugin configuration.

Ops Development & AI Practice
Ops Development & AI Practice
Ops Development & AI Practice
Why Jenkins Can’t Find Your ‘linux’ Label and How to Fix It on AWS EC2

Problem 1: Jenkins doesn’t have label ‘linux’

The pipeline was configured with agent { label 'linux' } but Jenkins stalled with the error “Still waiting to schedule task – Jenkins doesn’t have label ‘linux’”. The EC2 instance started, SSH worked, yet the agent never registered.

pipeline {
    agent { label 'linux' }
    stages {
        stage('Example') {
            steps {
                echo 'Running on linux node'
            }
        }
    }
}

Log analysis and solution

User configuration error : The AWS EC2 plugin defaults the Remote User to root, but Ubuntu images require the ubuntu user. The log repeatedly showed “Please login as the user \"ubuntu\" rather than the user \"root\".” Changing the Remote User to ubuntu resolves the authentication issue.

Init script mismatch : The plugin’s default init script runs Amazon Linux commands (

sudo amazon-linux-extras install java-openjdk11 -y; sudo yum install -y …

), which Ubuntu does not understand. Replacing it with Ubuntu‑compatible commands fixes the Java installation:

sudo apt-get update -y
sudo apt-get install -y openjdk-17-jdk
sudo apt-get install -y fontconfig

After updating the Remote User and Init Script, the linux label is recognized and the pipeline executes successfully.

Problem 2: AWS console filled with terminated instances

Each pipeline run terminates the EC2 instance, leaving it in the terminated state. AWS retains terminated instances for about an hour before automatically cleaning them up, which can clutter the console.

How to make them disappear

Hide with filters : In the EC2 console, add a filter Instance State != terminated and save it as the default view.

Optimize plugin configuration : Reduce Idle Termination Minutes (e.g., to 5 minutes) and set a reasonable Instance Cap to prevent creating too many instances at once. Consider stopping instances for reuse instead of terminating them.

Patience : If you can wait, AWS will automatically purge terminated instances within roughly one hour.

Best practices for using Jenkins + AWS EC2 plugin

Match AMI and scripts : Use apt-get commands for Ubuntu AMIs and yum for Amazon Linux AMIs; never mix them.

Check logs early : Open Manage Jenkins → System Log to locate the majority of configuration problems.

Control instance lifecycle : Adjust termination settings and filters to keep the console tidy and avoid accumulation of terminated instances.

Test configuration manually : After changes, SSH into the instance (e.g., ssh -i key.pem ubuntu@<IP>) and run java -version to confirm the environment is correct.

Following these steps turns a frustrating CI/CD setup into a smooth, automated workflow.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ci/cdDevOpslinuxPipelineJenkinsDynamic AgentsAWS EC2
Ops Development & AI Practice
Written by

Ops Development & AI Practice

DevSecOps engineer sharing experiences and insights on AI, Web3, and Claude code development. Aims to help solve technical challenges, improve development efficiency, and grow through community interaction. Feel free to comment and discuss.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.