我是Jenkins的初学者。我不知道哪个语法会出错。
请推荐Groovy语法检查工具,它们可以帮助您解决问题或解决问题
//我的Jenkinsfile
podTemplate(label: 'hello',
containers: [
containerTemplate(
name: 'git',
image: 'alpine/git',
ttyEnabled: true,
command: 'cat'
),
containerTemplate(
name: 'docker',
image: 'docker:latest',
ttyEnabled: true,
command: 'cat'
),
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
]
) {
node('hello') {
def appImage
def hubCred = docker-hub-token
stage('Checkout') {
container('git') {
checkout scm
}
}
stage('Build') {
container('docker'){
script {
appImage = docker.build yeawonkim/momssi
}
}
}
stage('Push'){
container('docker'){
script {
docker.withRegistry('', docker-hub-token){
appImage.push("0.0.1")
}
}
}
}
}
}
//jenkins控制台输出
Still waiting to schedule task
‘Jenkins’ doesn’t have label ‘hello’
Created Pod: kubernetes jenkins-kdev/hello-w4sjc-wg8jt
Agent hello-w4sjc-wg8jt is provisioned from template hello-w4sjc
---
apiVersion: "v1"
kind: "Pod"
metadata:
annotations:
buildUrl: "http://jenkins:8080/job/momssi-laravel/job/master/22/"
runUrl: "job/momssi-laravel/job/master/22/"
labels:
jenkins: "slave"
jenkins/label-digest: "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
jenkins/label: "hello"
name: "hello-w4sjc-wg8jt"
namespace: "jenkins-kdev"
spec:
containers:
- command:
- "cat"
image: "alpine/git"
imagePullPolicy: "IfNotPresent"
name: "git"
resources: {}
tty: true
volumeMounts:
- mountPath: "/var/run/docker.sock"
name: "volume-0"
readOnly: false
- mountPath: "/home/jenkins/agent"
name: "workspace-volume"
readOnly: false
- command:
- "cat"
image: "docker:latest"
imagePullPolicy: "IfNotPresent"
name: "docker"
resources: {}
tty: true
volumeMounts:
- mountPath: "/var/run/docker.sock"
name: "volume-0"
readOnly: false
- mountPath: "/home/jenkins/agent"
name: "workspace-volume"
readOnly: false
- env:
- name: "JENKINS_SECRET"
value: "********"
- name: "JENKINS_TUNNEL"
value: "jenkins-agent:50000"
- name: "JENKINS_AGENT_NAME"
value: "hello-w4sjc-wg8jt"
- name: "JENKINS_NAME"
value: "hello-w4sjc-wg8jt"
- name: "JENKINS_AGENT_WORKDIR"
value: "/home/jenkins/agent"
- name: "JENKINS_URL"
value: "http://jenkins:8080/"
image: "jenkins/inbound-agent:3142.vcfca_0cd92128-1"
name: "jnlp"
resources:
requests:
memory: "256Mi"
cpu: "100m"
volumeMounts:
- mountPath: "/var/run/docker.sock"
name: "volume-0"
readOnly: false
- mountPath: "/home/jenkins/agent"
name: "workspace-volume"
readOnly: false
nodeSelector:
kubernetes.io/os: "linux"
restartPolicy: "Never"
volumes:
- hostPath:
path: "/var/run/docker.sock"
name: "volume-0"
- emptyDir:
medium: ""
name: "workspace-volume"
Running on hello-w4sjc-wg8jt in /home/jenkins/agent/workspace/momssi-laravel_master
[Pipeline] {
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 1cdc9378-a61a-4881-8a2a-00e1f1e31ed4
groovy.lang.MissingPropertyException: No such property: hub for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:285)
at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:375)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:379)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at org.jenkinsci.plugins.workflow.cps.LoggingInvoker.getProperty(LoggingInvoker.java:121)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:22)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:73)
at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:65)
at jdk.internal.reflect.GeneratedMethodAccessor348.invoke(Unknown Source)
Jenkins在kubernetes上以pod形式运行。我的laravel项目包含jenkinsfile,当我试图在jenkins上构建这个项目时,我得到了一个错误。
1条答案
按热度按时间vuv7lop31#
在这种情况下,Groovy语法的问题就在这里
groovy中的标识符不能有
-
字符。Visual Studio Code和IntelliJ IDEA提供了一些用于groovy的静态代码分析工具。