jenkins 警告:无法在工作区中找到“report-task.txt”

b1payxdu  于 2023-02-03  发布在  Jenkins
关注(0)|答案(1)|浏览(328)

我的stage sonarqube总是无法运行作业,我已经确保服务器是正确的。
控制台输出

Started by user Jesaya Fernando Napitupulu
Obtained Jenkinsfile from git http://10.8.60.132/jesaya/simple-webapp.git
[Pipeline] Start of Pipeline
[Pipeline] podTemplate
[Pipeline] {
[Pipeline] node
Created Pod: kubernetes jenkins/xjoj-61-kw27q-npzb8-x2q9c
[Normal][jenkins/xjoj-61-kw27q-npzb8-x2q9c][Scheduled] Successfully assigned jenkins/xjoj-61-kw27q-npzb8-x2q9c to microk8s-worker
[Normal][jenkins/xjoj-61-kw27q-npzb8-x2q9c][Pulled] Container image "docker.io/library/openjdk:11.0.14.1-jre" already present on machine
[Normal][jenkins/xjoj-61-kw27q-npzb8-x2q9c][Created] Created container jdk
[Normal][jenkins/xjoj-61-kw27q-npzb8-x2q9c][Started] Started container jdk
[Normal][jenkins/xjoj-61-kw27q-npzb8-x2q9c][Pulled] Container image "jenkins/inbound-agent:4.11-1-jdk11" already present on machine
[Normal][jenkins/xjoj-61-kw27q-npzb8-x2q9c][Created] Created container jnlp
[Normal][jenkins/xjoj-61-kw27q-npzb8-x2q9c][Started] Started container jnlp
Agent xjoj-61-kw27q-npzb8-x2q9c is provisioned from template xjoj_61-kw27q-npzb8
---
apiVersion: "v1"
kind: "Pod"
metadata:
  annotations:
    buildUrl: "http://10.8.60.132:8880/job/'joj/61/"
    runUrl: "job/'joj/61/"
  labels:
    jenkins: "slave"
    jenkins/label-digest: "f4a24cf79b1ba88f85dc929f1365e192a6cbf6ee"
    jenkins/label: "xjoj_61-kw27q"
  name: "xjoj-61-kw27q-npzb8-x2q9c"
  namespace: "jenkins"
spec:
  containers:
  - image: "docker.io/library/openjdk:11.0.14.1-jre"
    name: "jdk"
    tty: true
    volumeMounts:
    - mountPath: "/home/jenkins/agent"
      name: "workspace-volume"
      readOnly: false
  - env:
    - name: "JENKINS_SECRET"
      value: "********"
    - name: "JENKINS_AGENT_NAME"
      value: "xjoj-61-kw27q-npzb8-x2q9c"
    - name: "JENKINS_WEB_SOCKET"
      value: "true"
    - name: "JENKINS_NAME"
      value: "xjoj-61-kw27q-npzb8-x2q9c"
    - name: "JENKINS_AGENT_WORKDIR"
      value: "/home/jenkins/agent"
    - name: "JENKINS_URL"
      value: "http://10.8.60.132:8880/"
    image: "jenkins/inbound-agent:4.11-1-jdk11"
    name: "jnlp"
    resources:
      limits: {}
      requests:
        memory: "256Mi"
        cpu: "100m"
    volumeMounts:
    - mountPath: "/home/jenkins/agent"
      name: "workspace-volume"
      readOnly: false
  nodeSelector:
    kubernetes.io/os: "linux"
  restartPolicy: "Never"
  volumes:
  - emptyDir:
      medium: ""
    name: "workspace-volume"

Running on xjoj-61-kw27q-npzb8-x2q9c in /home/jenkins/agent/workspace/'joj
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
The recommended git tool is: NONE
using credential fcf5851b-d66d-4536-9c17-c298d681ff4b
Cloning the remote Git repository
Cloning repository http://10.8.60.132/jesaya/simple-webapp.git
 > git init /home/jenkins/agent/workspace/'joj # timeout=10
Fetching upstream changes from http://10.8.60.132/jesaya/simple-webapp.git
 > git --version # timeout=10
 > git --version # 'git version 2.30.2'
using GIT_ASKPASS to set credentials GitLab - @jesaya
 > git fetch --tags --force --progress -- http://10.8.60.132/jesaya/simple-webapp.git +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
Checking out Revision 7754fca1b5b3bfba7bbb856c933fda5f4704d9ae (refs/remotes/origin/master)
 > git config remote.origin.url http://10.8.60.132/jesaya/simple-webapp.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 7754fca1b5b3bfba7bbb856c933fda5f4704d9ae # timeout=10
Commit message: "Update Jenkinsfile"
 > git rev-list --no-walk 24d08d802f19788bd1273eb9a384d1fad98d8048 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (SAST)
[Pipeline] tool
Unpacking https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/4.7.0.2747/sonar-scanner-cli-4.7.0.2747.zip to /home/jenkins/agent/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar-scanner on xjoj-61-kw27q-npzb8-x2q9c
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withSonarQubeEnv
Injecting SonarQube environment variables using the configuration: sonarqube-server
[Pipeline] {
[Pipeline] sh
process apparently never started in /home/jenkins/agent/workspace/'joj@tmp/durable-b5831242
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeed?
[Pipeline] // withSonarQubeEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE

配置我的sonarqube服务器:

我的声纳扫描仪工具的配置:

pipeline {
    agent {
        kubernetes {
            cloud 'kubernetes'
            namespace 'jenkins'
            yaml'''
            apiVersion: v1
            kind: Pod
            spec: 
              containers:
              - name: jdk
                image: docker.io/library/openjdk:11.0.14.1-jre
                tty: true
            '''
        }
    }
    stages {
        stage('SAST') {
            environment {
                SCANNER_HOME = tool 'sonar-scanner'
            }
            steps {
                withSonarQubeEnv('sonarqube-server') {
                    sh" ${SCANNER_HOME}}/bin/sonar-scanner \
                    -Dsonar.projectKey=simple_webapp \
                    -Dsonar.sources=. "
                }
            }
        }
    }
}

相关软件版本:

Sonarqube scanner: 4.7.0 2747
Sonarqube server: 8.9.8.54436
Jenkins: 2.332.2
Kubernetes (MicroK8s): 1.23.5-2+c812603a312d2b
Sonarqube Scanner plugin for Jenkins: 2.14
Kubernetes plugin for Jenkins: 3580.v78271e5631dc

这个管道只运行一个声纳扫描仪来扫描我的nodeiderjs代码。对于Jenkins一家自己来说,他们运行在一个从架构上。
有人知道这个管道哪里出错了吗?控制台输出没有提供错误的明确输出。

4si2a6ki

4si2a6ki1#

steps {
  withSonarQubeEnv('sonarqube-server') {
      sh" ${SCANNER_HOME**}**}/bin/sonar-scanner \
      -Dsonar.projectKey=simple_webapp \
      -Dsonar.sources=. "
  }
}

在SCANNER_HOME后删除额外的}

相关问题