0

I have setup a pipeline script, that will build a JAR using maven and the parameters are coming from Jenkins for the JAR. One of which is a password.

stages {
    stage('Maven Build') {
        steps {
            script {
                echo "Maven Build"
                withMaven(jdk: javaVersion, maven: mavenVersion) {
                    sh 'mvn clean install'
                }
            }
        }
    }
    stage('Branch Creation') {
        steps {
            script {
            sh """
            set +x 
            "java -jar target/github-branch-creator-1.0-SNAPSHOT-jar-with-dependencies.jar ${params.Username} ${params.Password} ${params.value1} ${params.value2} ${params.value3}"
            """
            }
        }
    }
} 

I did mention """ triple double quotes to accept the parameters from the jenkins, and did set +x, but it would still print the command in the console.

+java -jar target/github-branch-creator-1.0-SNAPSHOT-jar-with-dependencies.jar abc sensitive_password v1 v2 v2

I tried #!/bin/bash +x on top of my groovy script. I still found it to be printing. If someone can help?

Amar Kumar
  • 57
  • 8

1 Answers1

0

I think it would be better if you don't pass the password in plain text.

  • Ways you can try:

    Either encrypt the password then pass the arguments to command line, you can write to decrypt the same while using it in your java code.

    Write the command in file then execute the file.

marco525
  • 50
  • 11