J.Ghassen
J.Ghassen

Reputation: 101

How can I use build_number variable from jenkins as a tag for a reactjs docker image?

I'm trying to create a tag for each docker image generated with a jenkins job, for this I'm looking of how can I call an environment variable from jenkins such as build_number on my package.json

Thank you for your help.

Upvotes: 0

Views: 1241

Answers (2)

Prasanth
Prasanth

Reputation: 537

You can build your docker image from Jenkins job using following command.

docker build -f Dockerfile -t react-image:${env.BUILD_NUMBER} .

Upvotes: 1

Paolo
Paolo

Reputation: 121

It is not clear whether you want a version number defined inside package.json or the jenkins build number as the previous answer gave you.

In case you want a version number defined inside your package.json you could fetch it with grep inside a jenkins shell command and then use docker build as the above answer suggested.

If the version/build number is simply a shell environment variable, then you could use the environment variable injection plugin to export it to Jenkins.

Upvotes: 0

Related Questions