jenkins-library: xsDeploy to XSA: Can't use interactive confirmation without console!

Hi experts,

get this issue, when we try to deploy our .mtar file. Can’t use interactive confirmation without console! The login seems to work, but deployment doesn’t work. Any ideas?

  xsDeploy:    
    apiUrl: 'https://api.xxx:443' 
    credentialsId: 'gl_tbq_diraschk' # 'XS' is the default 
    dockerEnvVars: [http_proxy: "http://proxy:8080", https_proxy: "http://proxy:8080"]
    docker:
      dockerImage: '4d42e3c36023' 
    loginOpts: '--skip-ssl-validation'    
    org: 'orgname'
    space: 'TBASE'   

[Pipeline] { (hide)
[Pipeline] sh
info  xsDeploy - Using stageName 'deploy' from env variable 'STAGE_NAME'
info  xsDeploy - Project config: '.pipeline/config.yml'
info  xsDeploy - Project defaults: '.pipeline/additionalConfigs/default_pipeline_environment.yml'
debug xsDeploy - Skipping fetching secrets from vault since it is not configured
debug xsDeploy - Mode: 'DEPLOY', Action: 'NONE'
debug xsDeploy - performLogin: true, performLogout: true
debug xsDeploy - Performing xs login. api-url: 'https://api.xxx:443', org: 'orgname', space: 'TBASE'
info  xsDeploy - running shell script: /bin/bash #!/bin/bash
xs login -a https://api.xxx:443 -u **** -p '****' -o orgname -s TBASE --skip-ssl-validation


API_URL: https://api.xxx:443
The authenticity of host 'api.xxx' is not validated!
USERNAME: ****
Authenticating...
ORG: orgname
SPACE: TBASE
API endpoint:   https://api.xxx:443 (API version: 1)
User:           ****
Org:            orgname
Space:          TBASE

info  xsDeploy - xs login has been performed. api-url: 'https://api.xxx:443', org: 'orgname', space: 'TBASE'
debug xsDeploy - Copying xs session file from home directory ('/home/piper/.xsconfig') to workspace ('.xsconfig')
debug xsDeploy - xs session file copied from home directory ('/home/piper/.xsconfig') to workspace ('.xsconfig')
debug xsDeploy - Copying xs session file from workspace ('.xsconfig') to home directory ('/home/piper/.xsconfig')
debug xsDeploy - xs session file copied from workspace ('.xsconfig') to home directory ('/home/piper/.xsconfig')
info  xsDeploy - Performing xs deploy.
info  xsDeploy - running shell script: /bin/bash #!/bin/bash
xs deploy TBASE_1.1.13.mtar 

Can't use interactive confirmation without console!
debug xsDeploy - Performing xs logout.
info  xsDeploy - running shell script: /bin/bash #!/bin/bash
xs logout

Logging out...
OK

info  xsDeploy - xs logout has been performed
debug xsDeploy - xs session file '.xsconfig' has been deleted from workspace
warn  xsDeploy - Here are the logs (/home/piper/.xs_logs):
info  xsDeploy - File: '.xs_0.log.lock'
info  xsDeploy - File: 'xs_0.log'
# XS command line client version: v1.0.131 (built 2020-12-17 14:23:11, codeline REL, SAP SE)
# [2021-04-13 17:01:54:448] xs login -a https://api.xxx:443 -u <hidden> -p <hidden> -o orgname -s TBASE --skip-ssl-validation


# XS command line client version: v1.0.131 (built 2020-12-17 14:23:11, codeline REL, SAP SE)
# [2021-04-13 17:01:58:213] xs deploy TBASE_1.1.13.mtar

[2021-04-13 17:02:01:163]-[CLI]-[error]-[.]-[.]: Can't use interactive confirmation without console!

# XS command line client version: v1.0.131 (built 2020-12-17 14:23:11, codeline REL, SAP SE)
# [2021-04-13 17:02:01:415] xs logout

Would like to watch the logs, but don’t know how to open the piper file"/home/piper" (unzip doesn’t work)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

xs: not found

ah, yes. The other xs deploy statements (issued by the xsDeploy step) are certainly executed on your end in a docker container or k8s pod. All the statements inside the sh are most likely not.

Preferred way for solving this is executing the sh also in a docker container. That docker container needs to be based on the same docker image which you are also using for xsDeploystep itself. The step for using a docker container with the piper lib isdockerExecute or dockerExecuteOnKubernetes when using k8s. In prinicple dockerExecute forwards to dockerExecuteOnKubernetes automagically. As an example for how to get this running see here. This is exactly the code which also controls the docker handling we executing the xsDeploy step.

This means basically:

stage('deploy') {
            steps {
                xsDeploy script: this
                dockerExecute(script: this /* more parameters as required */) {                     
                    sh ''' #!/bin/bash     
                        xs login -a \${APIURL} -u \${USER_CREDENTIALS_USR} -p \${USER_CREDENTIALS_PSW} -o \${ORG} -s \${SPACE} \${LOGINOPTS}
                        xs ...
                        ...
               }
               

Docu for dockerExecute step is here. Can also be differently by having the sh in another stage and configuring the docker image via agent on that stage. More details for that see here. In that case we don’t need the dockerExecute from the piper lib.

Just for having the complete picture: Another possibility would be to install the xs command line on the Jenkins where the sh is executed. But I clearly recommend the other way with using the docker image.

Hope this helps & best regards, Marcus

And do I have to set the environment variables separately or are they already accessible during the xsDeploy-process?

… ahhh, forgot this: needs to be set separately. As outlined below sh is executed stand-alone and not inside a closure of xsDeploy.

Hi @diraschk , you are using a declarative pipeline. In this case it should be something like this (without warranty, just as a sketch):

pipeline {
 environment {
        EXAMPLE_CREDS = credentials('example-credentials-id')
        ORG = 'myOrg'
        ... more variables here as needed ...
    }

  stages {
    stage('deploy') {
      steps {
        xsDeploy script: this // sh is not inside a closure to xsDeploy, that is an other stand-alone step.
        sh """#/bin/bash
            xs login -a {{.APIURL}} -u \${EXAMPLE_CREDS_USR} -p \${EXAMPLE_CREDS_PSW} -o \${ORG} -s {{.Space}} {{.LoginOpts}}
            xs map-route TBASE.web tbase.charite.de --hostname TBASE
            xs set-env TBASE.web SESSION_TIMEOUT 60
            xs restage TBASE.web
            xs restart TBASE.web 
            xs logout
          """
        }
      }
    }
  }
}

For the withCredentials part in declarative pipelines see also here

Hope this helps & best regards, Marcus