-1

いくつかの調査を行った後、私はこれを思いつきましたpipelineが、これはエラーになります。

[セキュリティ] ページで資格情報を既にNexus構成しています。Jenkins上記の「ビルド」ステージで機能したパターンをたどろうとしていますが、うまくいきません。

このリンクhttps://plugins.jenkins.io/nexus-artifact-uploader/を見つけましたが、これはNexus 2.

コンパイル エラーが発生します。

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                withCredentials([usernamePassword(credentialsId: 'Bitbucket', usernameVariable: 'username', passwordVariable: 'password')]) {
                    git "https://${username}:${password}@bitbucket.org/${username}/greet.git"
                }
                sh "mvn clean deploy -DskipTests"
            }
        }
        stage('Publish') {
            steps {
                step {
                    withCredentials([usernamePassword(credentialsId: 'Nexus', usernameVariable: 'username', passwordVariable: 'password')]) {
                        def pom = readMavenPom file: 'pom.xml'
                        nexusArtifactUploader(
                            nexusVersion: 'nexus3',
                            protocol: 'http',
                            nexusUrl: '${username}:${password}@my-nexus-server/nexus',
                            groupId: '${pom.groupId}',
                            version: '${pom.version}',
                            repository: 'maven-snapshots',
                            credentialsId: 'Nexus',
                            artifacts: [
                                [artifactId: '${pom.artifactId}',
                                    classifier: '',
                                    file: '${pom.artifactId}-${pom.version}.jar',
                                    type: 'jar']
                            ]
                        )
                    }
                }
            }
        }
    }
}

エラー:

Started by user Admin
Obtained Jenkinsfile from git https://chandeln@bitbucket.org/chandeln/greet.git
Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 16: Expected a step @ line 16, column 25.
                           def pom = readMavenPom file: 'pom.xml'
                           ^

WorkflowScript: 14: Missing required parameter: "delegate" @ line 14, column 17.
                   step {
                   ^

2 errors

    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
    at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
    at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
    at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
    at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:428)
Finished: FAILURE
4

1 に答える 1