What’s in THIS environment?

We work on multiple java web projects going on at the same time and those are all being tested on several different QA environments. Id like to show on our support portal what projects are in what environments without having to manually updated it all the time. I was thinking of some what to tag the build so I could just query tomcat or those linux servers themselves and show the results. The tags would be something like “August Release”, “Project 1”, “Project 2”, etc.. Has anyone done something similar? I’m looking for different options.

Go to Source
Author: DaveTX

Deploy .NET application from Jenkins on Linux to MS Azure Web service

We have .NET application which deployed to Azure Web services. Now is time to create deployment pipeline for it.

And want to know what is high level plan how .NET application can be deployed to Azure from Linux servers based on CentOS.

Do we need an AZ cli installed on Linux server to deploy it and Azure .NET SDK?

Go to Source
Author: pleyades

yaml files in jenkins pipeline

Just started out working on jenkins, among other things I’m trying to understand the role of yaml in pipelines. I understand that pipelines or declarative pipeline (do other type of pipelines exist in jenkins?) are defined using a syntax that is based on an extension of groovy and that yaml can be used along with some plugins or extended library to generate an on the fly groovy-based pipeline definition. Is my understanding correct?

Go to Source
Author: whatever

How to determine whether the Jenkins build was started by a user or the scheduler?

I have a Jenkins job which does some unit-testing for some code. It can be started in two possible ways:

  1. By the scheduler – it polls the Perforce server, and starts the job when it detects a code change
  2. By a user, on demand – it downloads a shelved/stashed code change, and checks whether it breaks the tests

The second way is called “Build Review”:

Build Review

If the job discovers problems, I want to send emails conditionally, to avoid spam:

  1. If invoked by the scheduler, send mails to everyone who did check-ins since last successful build (called “developers” in Jenkins jargon)
  2. If invoked by a specific user, send a mail only to that user

I am using the Any Build Step plugin to add two conditional instances of Editable email Notification into my job settings. But what are the conditions? How can I tell it to send mail only if invoked in a specific way, (1) or (2) above?

Go to Source
Author: anatolyg

Unable to get value of password parameter into another parameter

In Jenkins pipeline parameter say Branches of type Active Choice Reactive Parameter, I’ve to auto-populate branch names hence I’ve following command, which I can execute in parameter’s Groovy script –

svn ls <url> --non-interactive --no-auth-cache --trust-server-cert --username <username>--password <password>

username can be retrieved using User.current().getId()

I’ve Password parameter of Password Parameter type. To use value of this parameter in Groovy script of Branches, I’ve added Password parameter in Referenced parameters of Branches

But I cannot see its value reflected in Branches parameter. Can you please suggest how this can be handled?

Or any other way to pass Password value or authentication details so I can execute svn command.

Go to Source
Author: TDHM

How to get logged in username of Jenkins in parameter’s Groovy script?

In Jenkins parameter, I’m writing Groovy script and in that script I need to pass Jenkins logged in username NOT user. User and username, could be different

Ex – User, that is displayed left to ‘log out’, could be – Bob Gill and username, used to login – could be – bob

User can be retrieved using User.current(). Please tell me how to get username.

NOTE I don’t need username in pipeline code. I need it in Groovy script of parameter.

Go to Source
Author: TDHM

Where would the Jenkins job run if I don’t mention any Agent labels?

I my Jenkins setup I have a few set of jobs which uses agent to build and deploy. I achieved it by mentioning the agent label in the job configurations.

I have one job which has to execute on the master jenkins. If i don’t mention any label in job configuration and if no agents are online, the job gets executed on master jenkins. If any agent is online, instead of executing in master jenkins, it picks up some random agent and executes the job. How can i execute it on master even if agents are online?

Go to Source
Author: B. Akshay

simulate post step for dynamically generated Jenkins pipeline stages

The following simplified Jenkinsfile dynamically generates sequentially executed stages; however, I cannot create a post step for these dynamically stages, like so:

pipeline {
    agent none
    stages {
        stage('Gen Stages') {
            steps {
                script {
                    def stageNames = ["st1", "st2", "st3"]
                    stageNames.each { stageName ->
    post {
        always {
            echo "post > always"
        success {
            echo "post > success"

def createStage(String stageName) {
    stage(stageName) {
        echo "Stage: ${stageName}"
    // I want to uncomment and use code below - or something effectively simiarl:
    // post {
    //     always {
    //         echo "${stageName} > post > always"
    //     }
    //     success {
    //         echo "${stageName} > success > always"
    //     }
    // }

I would like to be able to use the commented-out post {} stage, or something effectively similar.

If at all possible, I’d like to use the DSL as much as possible and avoid scripted pipelines.


Go to Source
Author: Trevor

How can I unify my distributed build environments using Jenkins and Docker?

I’ve recently taken over the CI management for a medium-sized team of developers. Currently, we have one Jenkins server instance as well as six other instances of Jenkins agents to build upon. We have been using labels to determine which builds to run. For example, some instances are setup to run under environments A or B. In the future, we would like to add more instances of A and B, as well as add new environments, e.g., C, D.

My goal now is to unify these build environments and define them in one place to allow for better scale-ability and ease of management of these instances. Docker seems to be a solution to this approach. I know that I can create a Docker image for each of my individual environments. What I don’t know is how to distribute the image into containers across my six machine instances. The solution I am looking for involves allowing multiple docker containers to be spun up on a single instance (docker host?), but only if needed (i.e., the scenario when all other hosts are currently hosting a container). Additionally, I need a solution that supports Windows and Linux based hosts.

I know that Docker support in Jenkins seems to be based largely via plugins, so I was hoping for some direction in which plugin to research first.

Thanks for your time.

Go to Source
Author: qgoehrig

Jenkins Plugin:Extended Choice Parameter from JSON file

Jenkins Plugin:Extended Choice Parameter from JSON file

Extended Choice Parameter plugin query: How to load params dynamically from a JSON file for jenkins build job. Here is my jenkins script to add normal parameters and Extended Choice parameters as well.


        [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '500']],
        defaultValue: 'One,Two,Three,Four', 
        description: '', 
        multiSelectDelimiter: ',', 
        name: 'SAMPLE_EXTENDED_CHOICE', 
        quoteValue: false, 
        saveJSONParameterToFile: false, 
        type: 'PT_CHECKBOX', 
        visibleItemCount: 10)

This is working. But I want to be able to load parameters from a JSON file (using Extended Choice Parameter plugin). How can I modify the above script to accomplish that? PS: Here is the reference for Extended Parameter plugin. https://plugins.jenkins.io/extended-choice-parameter/

Go to Source
Author: Vineel

how to run Docker/Jenkins behind a proxy

how to run Docker/Jenkins behind a proxy

For the past few days I’ve been scratching my head trying to get the Jenkins docker image to work

The issue appears to be a proxy issue.

OS: Ubuntu 16.04 LTS

Running behind work proxy

Docker version 19.03.5, build 633a0ea838


When I run the following command, I can’t access jenkins on localhost:7000

docker run --name myjenkins -p 7000:8000 -p 50000:50000 -v /var/jenkins_home jenkins

However I can with the following command

docker run --name myjenkins -p 7000:8080 -p 50000:50000 --env HTTP_PROXY=“http:// localhost:8080” --env HTTPS_PROXY=“https:// localhost:8080” -v /var/jenkins_home jenkins

The issue is, with the second command, I can access the jenkins but I can’t install plugins and it asks me to configure the proxy
Setting the proxy in the UI didn’t work

My understanding is that Jenkins look for port 8080 by default and because in the command above I’m using port 7000, this is preventing Jenkins from connecting to the internet (correct me if I’m wrong)

So what I did was download the Dockerfile for Jenkins and changed the port from 8080 to 7000


I am now attempting to build the image with the following command

docker build --tag jenkins:1.0 .

I get the following error

curl: (7) Failed to connect to github. com port 443: Connection timed out
The command ‘/bin/sh -c curl -fsSL https:// github. com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static-amd64 -o /bin/tini && chmod +x /bin/tini && echo “$TINI_SHA /bin/tini” | sha256sum -c -’ returned a non-zero code: 7

I suspect, this is a proxy issue and I did put proxy arguments in the Dockerfile but not sure if this is what I need to do or whether I’m doing it correctly

Any idea what could be the solution?

Thank you

Go to Source
Author: Sgr