Loran
Loran

Reputation: 842

Import Job to Jenkins from xml

I am new in jenkins and docker.I am trying to import jenkins new job from xml file.Current jenkins is running inside docker.(jenkinsci/blueocean).

Here is my command:

java -jar .\jenkins-cli.jar -s http://localhost:8080/ create-job jobname .\myjob.xml

Here is error:

anonymous is missing the Overall/Read permission

What I have done:

I already check this one

Anonymous is missing the Overall/Read permission

So I test with this cmd:

java -jar .\jenkins-cli.jar -s http://localhost:8080/ -auth username:password who-am-i

It return

 Authenticated as : username 
 Authorities: authenticated

Then I also try like that :

java -jar .\jenkins-cli.jar -s http://localhost:8080 create-job jobname .\myjob.xml -auth username:password

its also happen error.

Pls help.

Upvotes: 1

Views: 2963

Answers (1)

Adiii
Adiii

Reputation: 59966

I will prefer job import at build time, Here is the working example that you can try.

FROM jenkinsci/blueocean 
COPY config.xml /usr/share/jenkins/ref/jobs/job_name/config.xml

You can try working below command to run demo job import

git clone https://github.com/Adiii717/docker-jenkins-job-import.git
cd docker-jenkins-job-import;
docker-compose build
docker-compose up

Upvotes: 2

Related Questions